from django.conf import settings as django_settings from fabric.operations import local def _notify(message): if django_settings.FAB_NOTIFY_TASK_ENDS: local(u'notify-send --expire-time=10000 "Fabric notify" "{}"'.format(message))
from fab_utils import _notify def mongo_get_from_remote(server='', date='', collection=''): u""" c """ ... _notify(u" ")
def notified(wrapped): def internal(*args, **kwargs): res = wrapped(*args, **kwargs) params = [unicode(a) for a in args] params.extend([u'{}={}'.format(k, v) for k, v in kwargs.iteritems()]) params = [_limit_str(p) for p in params] message = "{}({}) ended!!!".format(wrapped.__name__, ', '.join(params)) _notify(message) return res return internal
from fab_utils import notified @notified def mongo_get_from_remote(server='', date='', collection=''): u""" c """ ...
wad@wad-vaio:~/aggregator (develop)$ bin/fab.sh -d mongo_get_from_remote Displaying detailed information for task 'mongo_get_from_remote': No docstring provided Arguments:
def notified(wrapped): def internal(*args, **kwargs): ... return res internal.__doc__ = wrapped.__doc__ return internal
wad@wad-vaio:~/aggregator (develop!)$ bin/fab.sh -d mongo_get_from_remote Displaying detailed information for task 'mongo_get_from_remote': c Arguments:
def display_command(name): """ Print command function's docstring, then exit. Invoked with -d/--display. """ ... if hasattr(command, '__details__'): task_details = command.__details__() else: task_details = get_task_details(command) ...
from fabric.tasks import get_task_details def notified(wrapped): def internal(*args, **kwargs): res = wrapped(*args, **kwargs) params = [unicode(a) for a in args] params.extend([u'{}={}'.format(k, v) for k, v in kwargs.iteritems()]) params = [_limit_str(p) for p in params] message = "{}({}) ended!!!".format(wrapped.__name__, ', '.join(params)) _notify(message) return res def _details(): return get_task_details(wrapped) internal.__doc__ = wrapped.__doc__ internal.__details__ = _details return internal
wad@wad-vaio:~/aggregator (develop!)$ bin/fab.sh -d mongo_get_from_remote Displaying detailed information for task 'mongo_get_from_remote': c Arguments: server='', date='', collection=''
Source: https://habr.com/ru/post/214259/
All Articles