2

I have a number of tasks defined as Task subclasses and I have roledefs set similar to the following:

env.roledefs = { "web": ["1.2.3.4"], "db": ["5.6.7.8"] }

class Foo(Task):
  name = "foo"

  def run(self):
    pass

foo = Foo()

With the @roles decorator I can decorate tasks if they are functions in a module but I'm not sure how to apply this to Task classes. Decorating the class or its run function doesn't seem to work.

I'm using Fabric 1.4.0

4

1 回答 1

1

认为您应该能够像这样使用 init :

def __init__(self):
     env.roles = ['web']

或使用执行:

execute(foo, roles='web')
于 2012-09-13T23:55:33.843 回答