我在模块中定义了不同的环境:
__init__.py
def localdev():
"""
Work on local dev environment
"""
env.db_credentials = {'user':'username', 'pass':'passs','name':'mydb'}
env.uwsgi_command = 'uwsgi'
env.settings = 'local_dev'
env.hosts = ['dev@localhost']
dev production():
pass
deploy.py
中的
from __future__ import with_statement
import os
from fabric.api import *
from fabric.decorators import task
@task
def flush_cache(environment, ):
"""
Clear memcached cache
"""
sudo('/etc/init.d/memcached restart', pty=True)
fabfile.py
from mymodule import *
我现在应该如何在localdev环境中运行我的代码?
fab localdev deploy.flush_cache
Fatal error: Command(s) not found:
localdev
Aborting.
谢谢!
答案 0 :(得分:0)
您需要在fabfile.py中导入init.py.传递给结构的参数在fabfile.py中用作函数名称。由于您不导入模块,因此该功能不存在,因此您将收到命令not found error。