Created
July 5, 2018 17:30
-
-
Save ohtomi/21b60ea7d302c9e350878246ca1d3fa7 to your computer and use it in GitHub Desktop.
Fabric task function is wrapped by decorator.decorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from invoke import task, context | |
from decorator import decorator | |
def ctask(f, *args, **kwds): | |
print('wraps') | |
if len(args) >= 1 and isinstance(args[0], context.Context): | |
print('context!') | |
print(args[0]) | |
return | |
return f(*args, **kwds) | |
@task | |
@decorator(ctask) | |
def hello(c, name='tommy'): | |
"""this is hello""" | |
print(f'hello({name})') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fab hello | |
# wraps | |
# context! | |
# <Context: <Config: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': True, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>, 'remote': <class 'fabric.runners.Remote'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True, 'auto_dash_names': True, 'collection_name': 'fabfile', 'search_root': None}, 'connect_kwargs': {'key_filename': []}, 'forward_agent': False, 'gateway': None, 'load_ssh_configs': True, 'port': 22, 'ssh_config_path': None, 'timeouts': {'connect': None}, 'user': 'ohtomi'}>> | |
fab -l | |
# Available tasks: | |
# | |
# hello this is hello | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment