fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Exposed tasks via @task


From: Hajducko, Steven
Subject: Re: [Fab-user] Exposed tasks via @task
Date: Tue, 20 Dec 2011 10:15:36 -0800

Try using __all__

 

utils.py:

__all__ = [‘which’]

 

frobnosticate.py:

__all__ = [‘frobber’]

 

http://docs.fabfile.org/en/1.3.3/usage/tasks.html?highlight=__all__

 

You really don’t even need the __all__ in the utils.py.

 

fabfile/__init__.py:

 

import frobnosticate

import utils

 

fabfile/utils.py:

 

from fabric.api import *

 

@task

def which():

    pass

 

fabfile/frobnosticate.py:

 

from fabric.api import *

from test import which

 

__all__ = ['frobber']

 

@task

def frobber():

    which()

 

 

loki:fabtest stha3155$ fab -l

Available commands:

 

    frobnosticate.frobber

    utils.which

 

 

From: address@hidden [mailto:address@hidden On Behalf Of VanL
Sent: Monday, December 19, 2011 1:34 PM
To: address@hidden
Subject: [Fab-user] Exposed tasks via @task

 

Is there a way to limit tasks to the context in which they are exposed? For example, I like to build up a number of subfunctions that may be individually useful, mark them as @tasks, and then have higher-level tasks that use a number of these subfunctions to perform some scripted action. If the subfunction task is imported from another module, it results in the task name being repeated in both contexts. For example:

fabfile.py/
  /__init__.py
  /utils.py # defines "which"
  /frobnosticate.py # imports "which" from utils and uses it in the function "frobber"


fab -l
  utils.which
  frobnosticate.frobber
  frobnosticate.which

In this case, frobnosticate.which *is* utils.which. Is it possible to keep tasks marked by the @task decorator to the context in which they are defined?

Thanks,

Van


reply via email to

[Prev in Thread] Current Thread [Next in Thread]