我正在使用Fabric 1.8编写几个任务
由于他们中的大多数都非常相似,我想做以下事情:
# Decorator for installation task
def install_task(test_task):
def impl(install):
def wrapper(*args, **kwargs):
if not test_task():
install()
return test_task()
return wrapper
return impl
# Decorator for test task
def test_task(expected):
def impl(test):
def wrapper(*args, **kwargs):
return expected in test()
return wrapper
return impl
# JAVA
@test_task('java version "1.7')
def test_java():
return run('java -version')
@install_task(test_java)
def install_java():
with sudo('apt-get purge openjdk*'):
with sudo('apt-get install software-properties-common'):
with sudo('add-apt-repository ppa:webupd8team/java'):
with sudo('apt-get update'):
sudo('apt-get install oracle-java7-installer')
但是当我尝试运行任务时,我得到:
Available commands:
wrapper
Fabric是否与自定义参数化装饰器兼容?