{"id":214259,"date":"2014-02-28T19:14:02","date_gmt":"2014-02-28T15:14:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=214259"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=214259","title":{"rendered":"<span class=\"post_title\">\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0439 fabric \u0437\u0430\u0434\u0430\u0447, \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u043b\u0433\u043e\u0438\u0433\u0440\u0430\u044e\u0449\u0438\u0435 fab-\u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u2014 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043c\u043f\u043e\u0432 \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0442\u0441. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0448\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043e\u0442\u0432\u043b\u0435\u043a\u0430\u0435\u0448\u044c\u0441\u044f \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0435 \u043e\u043a\u043e\u0448\u043a\u043e, \u0447\u0435\u0440\u0435\u0437 N \u043c\u0438\u043d\u0443\u0442(\u0430 \u0442\u043e \u0438 \u0447\u0435\u0440\u0435\u0437 \u0447\u0430\u0441) \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0448\u044c, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0448\u044c\u2026 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. <br \/>  \u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u0435\u0441\u043a\u0442\u043e\u043f \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 \u0442\u0443\u0442 \u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e <a href=\"\/post\/47892\/\">notify-send<\/a> \u043f\u043e\u0434\u0432\u0435\u0440\u043d\u0443\u043b\u0430\u0441\u044c. \u0420\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 fab-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u0441\u0430\u043c\u043e\u0435 \u0435\u043c\u0443 \u043c\u0435\u0441\u0442\u043e. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f  <\/p>\n<pre><code class=\"python\">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 &quot;Fabric notify&quot; &quot;{}&quot;'.format(message)) <\/code><\/pre>\n<p>  \u0414\u0430, \u0443 \u043c\u0435\u043d\u044f \u0434\u0436\u0430\u043d\u0433\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u00ab\u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043b\u0438 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438\u00bb \u0432\u044b\u043d\u0435c\u0435\u043c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. <\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 _notify \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435:  <\/p>\n<pre><code class=\"python\">from fab_utils import _notify  def mongo_get_from_remote(server='', date='', collection=''):     u&quot;&quot;&quot;\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0431\u0430\u0437\u044b \u043c\u043e\u043d\u0433\u043e c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430&quot;&quot;&quot;     ...     _notify(u&quot;\u0411\u0430\u0437\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b&quot;) <\/code><\/pre>\n<p>  \u041d\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0432 \u043a\u043e\u043d\u0446\u0435\u2026 \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u00ab\u0441\u0443\u0445\u043e\u00bb (DRY \u0440\u0443\u043b\u0438\u0442). \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440  <\/p>\n<pre><code class=\"python\">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 = &quot;{}({}) ended!!!&quot;.format(wrapped.__name__, ', '.join(params))         _notify(message)         return res     return internal <\/code><\/pre>\n<p>  \u0418 \u0442\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0435  <\/p>\n<pre><code class=\"python\">from fab_utils import notified  @notified def mongo_get_from_remote(server='', date='', collection=''):     u&quot;&quot;&quot;\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0431\u0430\u0437\u044b \u043c\u043e\u043d\u0433\u043e c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430&quot;&quot;&quot;     ... <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \ud83d\ude41  <\/p>\n<pre><code class=\"bash\">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: <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c? \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043e\u043a\u0441\u0442\u0440\u0438\u043d\u0433!   <\/p>\n<pre><code class=\"python\">def notified(wrapped):     def internal(*args, **kwargs):         ...         return res     internal.__doc__ = wrapped.__doc__     return internal <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">wad@wad-vaio:~\/aggregator (develop!)$ bin\/fab.sh -d mongo_get_from_remote Displaying detailed information for task 'mongo_get_from_remote':      \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0431\u0430\u0437\u044b \u043c\u043e\u043d\u0433\u043e c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 server='', date='', collection=''     Arguments: <\/code><\/pre>\n<p>  \u0423\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0433\u0434\u0435 \u0436\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b? \u0417\u0430 \u043d\u0438\u043c\u0438 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043b\u0435\u0437\u0442\u044c \u0432 \u043a\u0438\u0448\u043e\u0447\u043a\u0438 fabric \u2014 \u043a\u0430\u043a \u043e\u043d \u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442?<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 env\/local\/lib\/python2.7\/site-packages\/fabric\/main.py:466 \u043d\u0430\u0448\u043b\u043e\u0441\u044c  <\/p>\n<pre><code class=\"python\">def display_command(name):     &quot;&quot;&quot;     Print command function's docstring, then exit. Invoked with -d\/--display.     &quot;&quot;&quot;     ...     if hasattr(command, '__details__'):         task_details = command.__details__()     else:         task_details = get_task_details(command)     ... <\/code><\/pre>\n<p>  \u0410\u0433\u0430, \u0435\u0441\u043b\u0438 \u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0435\u0441\u0442\u044c __details__ \u0442\u043e \u043e\u043d \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041e\u0442\u043b\u0438\u0447\u043d\u043e! <\/p>\n<p>  \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0442\u0430\u043a\u043e\u0432  <\/p>\n<pre><code class=\"python\">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 = &quot;{}({}) ended!!!&quot;.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  <\/code><\/pre>\n<p>  \u0418 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 fab-\u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435  <\/p>\n<pre><code class=\"bash\">wad@wad-vaio:~\/aggregator (develop!)$ bin\/fab.sh -d mongo_get_from_remote Displaying detailed information for task 'mongo_get_from_remote':      \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0431\u0430\u0437\u044b \u043c\u043e\u043d\u0433\u043e c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 server='', date='', collection=''     Arguments: server='', date='', collection=''  <\/code><\/pre>\n<p>  \u041b\u044e\u0431\u043b\u044e python \ud83d\ude42<br \/>  <habracut\/>    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/214259\/\"> http:\/\/habrahabr.ru\/post\/214259\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u043b\u0433\u043e\u0438\u0433\u0440\u0430\u044e\u0449\u0438\u0435 fab-\u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u2014 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043c\u043f\u043e\u0432 \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0442\u0441. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0448\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043e\u0442\u0432\u043b\u0435\u043a\u0430\u0435\u0448\u044c\u0441\u044f \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0435 \u043e\u043a\u043e\u0448\u043a\u043e, \u0447\u0435\u0440\u0435\u0437 N \u043c\u0438\u043d\u0443\u0442(\u0430 \u0442\u043e \u0438 \u0447\u0435\u0440\u0435\u0437 \u0447\u0430\u0441) \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0448\u044c, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0448\u044c\u2026 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. <br \/>  \u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u0435\u0441\u043a\u0442\u043e\u043f \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 \u0442\u0443\u0442 \u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e <a href=\"\/post\/47892\/\">notify-send<\/a> \u043f\u043e\u0434\u0432\u0435\u0440\u043d\u0443\u043b\u0430\u0441\u044c. \u0420\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 fab-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u0441\u0430\u043c\u043e\u0435 \u0435\u043c\u0443 \u043c\u0435\u0441\u0442\u043e.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-214259","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/214259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214259"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/214259\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}