2015-10-15 38 views

回答

0

這看起來好像沒什麼問題:

fabfile.py

from fabric.api import task 

@task(alias='not') 
def _not(): 
    print 'not called' 

@task(alias='in') 
def _in(): 
    print 'in called' 

@task(alias='while') 
def _while(): 
    print 'while called' 

舊式:

from fabric import state 

def _not(): 
    print 'not called' 

def _in(): 
    print 'in called' 

def _while(): 
    print 'while called' 

state.commands['not'] = _not 
state.commands['in'] = _in 
state.commands['while'] = _while 

,並運行它。

$ fab not while in 
not called 
while called 
in called 

Done. 

另外。下一次將python添加到標籤,這幾乎不可能「找到」 - 哈哈。

+0

增加了python標籤。我發現我可以使用@task裝飾器進行這項工作,但我需要使用經典方法。 – user5095359

+0

你正在使用的python和結構的版本是什麼? –

+0

python-2.7.6,fabric-1.10.2 – user5095359

相關問題