我想在Fabric中更改目录和运行命令

时间:2015-01-12 13:49:49

标签: python django fabric

我想更改目录,当我用cd('myApp')运行命令时,我得到:

No hosts found. Please specify (single) host string for connection:

我有这段代码:

def example():
    local('sudo apt-get install python-dev libmysqlclient-dev')
    local('pip install MySQL-python')
    local('sudo apt-get install apache2')
    with cd('myApp'):
        run('pwd')
        run('python manage.py syncdb --no-initial-data')
        run('python manage.py migrate')
    print(green('DONE.'))

1 个答案:

答案 0 :(得分:1)

根据官方教程,错误指定您尚未在fabfile中指定连接以进行部署。请检查here

除此之外,在cd方法(与with语句一起使用)中,使用完整路径,如

with cd('/path/to/directory/myApp')

而不仅仅是'myApp'。即使它只是'/ myApp'。它提高了可读性,并确保这是你想要的路径。

相关问题