Saturday 15 May 2010

python - How to add a custom decorator to a fabric task -


OK, I have to admit that I am new to clothes and even a dragon is but me It is interested in doing it right, so ... I want to decorate some of my works with the ready function which adds some wars to env first Based on the people given only Look: importing fabric.api from import import fabstork.project.base utils def as fabstork.utils.drupal import (function): "" "set some extra For decorator environment variables "def Ready (* Args, ** kwargs): env.sites_folder = env.sites_folder if 'sites_folder' env other 'default' env.settings_file ="% s / www / sites /% s / in settings To come back to work "% (env.build_path, env.sites_folder) return jobs (* args, ** kwargs), create more @task @prepare def push (ref = 'HEAD'):" "" Host "" "" Bishopash (referee) utils.settings_php () utils.link_files () utils.set_perms ()

The example given above fails for that push is no longer a task, it is not in the list of available tasks while doing the fab --list on the command line. Leaving aside leads to an ideal work. What am I doing wrong?

to fabric .decorators import work from import to FontLoulles def custom_descorator (funk): @ WPS (Func) DEF decorated (* Args, ** kwargs): Print "This ceremony is decorated." Return Function (* argets, ** kwargs) decorated back @task @ custom_decorator def some_function (): print "this is the function"

Result:

  # Fab-El & gt; Available orders: & gt; & Gt; Some_function # fab some_function & gt; This function is decorated & Gt; This function is & gt; & Gt; done.    

No comments:

Post a Comment