fabric 没有获取 Django 环境
fabric is not getting Django environment
我的本地系统中有一个结构文件,我用它在远程服务器(在 virtualenv 中)部署代码并想测试它。方法定义如下。
def test_deploy(gitid = '930bfc4'):
# manually put the commit id at the end
path = '/tmp/testapp/app1/source/demo4'
with cd(path):
commit_id = 'git fetch https://myaccount@github.org/myaccount/demo4.git/heads/master:https://myaccount@github.org/myaccount/demo4.git/remotes/origin/master/'+gitid
# change the settings.py file and update the database
run (commit_id)
run ('cat .git/FETCH_HEAD')
path1 = '/tmp/testvehic/vehic'
with cd(path1):
run ('pwd')
env.activate = 'source /tmp/testapp/app1/bin/activate'
run ('python /tmp/testapp/app1/source/demo4/manage.py test')`
表示
ImportError: No module named django.core.management
在 Google 中进行一些搜索后,我才知道它实际上并没有定位我的 django 环境。
我的虚拟环境路径是/tmp/testapp/app1
源代码在 /tmp/testapp/app1/source/app1/
当我 运行 服务器终端中的命令 python manage.py test
工作正常。我怎样才能通过面料进行测试?
我从下面得到了答案link
http://nurupoga.org/articles/deployment-with-fabric-and-virtualenv/
我的代码片段现在看起来像这样
VENV_DIR = '/home/rootuser/testvehic/vehic'
PROJECT_DIR = '/home/rootuser/testvehic/vehic/source/cabsdemo4'
@contextmanager
def source_virtualenv():
with prefix('source ' + os.path.join(VENV_DIR, 'bin/activate')):
yield
def test_deploy(gitid = '930bfc4'):
# manually put the commit id at the end
path = '/tmp/testapp/app1/source/demo4'
with cd(path):
commit_id = 'git fetch https://myaccount@github.org/myaccount/demo4.git/heads/master:https://myaccount@github.org/myaccount/demo4.git/remotes/origin/master/'+gitid
# change the settings.py file and update the database
run (commit_id)
run ('cat .git/FETCH_HEAD')
with settings(warn_only=True):
with cd(PROJECT_DIR):
with source_virtualenv():
run('pip install -r requirements.txt')
run('python manage.py test')
我的本地系统中有一个结构文件,我用它在远程服务器(在 virtualenv 中)部署代码并想测试它。方法定义如下。
def test_deploy(gitid = '930bfc4'):
# manually put the commit id at the end
path = '/tmp/testapp/app1/source/demo4'
with cd(path):
commit_id = 'git fetch https://myaccount@github.org/myaccount/demo4.git/heads/master:https://myaccount@github.org/myaccount/demo4.git/remotes/origin/master/'+gitid
# change the settings.py file and update the database
run (commit_id)
run ('cat .git/FETCH_HEAD')
path1 = '/tmp/testvehic/vehic'
with cd(path1):
run ('pwd')
env.activate = 'source /tmp/testapp/app1/bin/activate'
run ('python /tmp/testapp/app1/source/demo4/manage.py test')`
表示
ImportError: No module named django.core.management
在 Google 中进行一些搜索后,我才知道它实际上并没有定位我的 django 环境。
我的虚拟环境路径是/tmp/testapp/app1
源代码在 /tmp/testapp/app1/source/app1/
当我 运行 服务器终端中的命令 python manage.py test
工作正常。我怎样才能通过面料进行测试?
我从下面得到了答案link
http://nurupoga.org/articles/deployment-with-fabric-and-virtualenv/
我的代码片段现在看起来像这样
VENV_DIR = '/home/rootuser/testvehic/vehic'
PROJECT_DIR = '/home/rootuser/testvehic/vehic/source/cabsdemo4'
@contextmanager
def source_virtualenv():
with prefix('source ' + os.path.join(VENV_DIR, 'bin/activate')):
yield
def test_deploy(gitid = '930bfc4'):
# manually put the commit id at the end
path = '/tmp/testapp/app1/source/demo4'
with cd(path):
commit_id = 'git fetch https://myaccount@github.org/myaccount/demo4.git/heads/master:https://myaccount@github.org/myaccount/demo4.git/remotes/origin/master/'+gitid
# change the settings.py file and update the database
run (commit_id)
run ('cat .git/FETCH_HEAD')
with settings(warn_only=True):
with cd(PROJECT_DIR):
with source_virtualenv():
run('pip install -r requirements.txt')
run('python manage.py test')