ó
P'—^c           @@ sa  d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l m Z m Z d d l m Z d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z m Z d d l m  Z  m! Z! d d l" m# Z# d g Z$ e% d „  e& e ƒ Dƒ ƒ Z' e( d „  e' Dƒ ƒ Z) d Z* e d d d d d f ƒ Z+ d „  Z, d Z- e
 j. d d f k  rµd Z- n  d „  Z/ d e0 f d „  ƒ  YZ1 d  d! d! d! d" „ Z2 d# e0 f d$ „  ƒ  YZ3 d% „  Z4 d& „  Z5 e6 d' „ Z7 d( „  Z8 e j9 d) „ Z: d* „  Z; d+ „  Z< e= d, k r]e, ƒ  n  d S(-   u"  

.. program:: celery multi

Examples
========

.. code-block:: bash

    # Single worker with explicit name and events enabled.
    $ celery multi start Leslie -E

    # Pidfiles and logfiles are stored in the current directory
    # by default.  Use --pidfile and --logfile argument to change
    # this.  The abbreviation %N will be expanded to the current
    # node name.
    $ celery multi start Leslie -E --pidfile=/var/run/celery/%N.pid
                                    --logfile=/var/log/celery/%N.log


    # You need to add the same arguments when you restart,
    # as these are not persisted anywhere.
    $ celery multi restart Leslie -E --pidfile=/var/run/celery/%N.pid
                                     --logfile=/var/run/celery/%N.log

    # To stop the node, you need to specify the same pidfile.
    $ celery multi stop Leslie --pidfile=/var/run/celery/%N.pid

    # 3 workers, with 3 processes each
    $ celery multi start 3 -c 3
    celery worker -n celery1@myhost -c 3
    celery worker -n celery2@myhost -c 3
    celery worker -n celery3@myhost -c 3

    # start 3 named workers
    $ celery multi start image video data -c 3
    celery worker -n image@myhost -c 3
    celery worker -n video@myhost -c 3
    celery worker -n data@myhost -c 3

    # specify custom hostname
    $ celery multi start 2 --hostname=worker.example.com -c 3
    celery worker -n celery1@worker.example.com -c 3
    celery worker -n celery2@worker.example.com -c 3

    # specify fully qualified nodenames
    $ celery multi start foo@worker.example.com bar@worker.example.com -c 3

    # Advanced example starting 10 workers in the background:
    #   * Three of the workers processes the images and video queue
    #   * Two of the workers processes the data queue with loglevel DEBUG
    #   * the rest processes the default' queue.
    $ celery multi start 10 -l INFO -Q:1-3 images,video -Q:4,5 data
        -Q default -L:4,5 DEBUG

    # You can show the commands necessary to start the workers with
    # the 'show' command:
    $ celery multi show 10 -l INFO -Q:1-3 images,video -Q:4,5 data
        -Q default -L:4,5 DEBUG

    # Additional options are added to each celery worker' comamnd,
    # but you can also modify the options for ranges of, or specific workers

    # 3 workers: Two with 3 processes, and one with 10 processes.
    $ celery multi start 3 -c 3 -c:1 10
    celery worker -n celery1@myhost -c 10
    celery worker -n celery2@myhost -c 3
    celery worker -n celery3@myhost -c 3

    # can also specify options for named workers
    $ celery multi start image video data -c 3 -c:image 10
    celery worker -n image@myhost -c 10
    celery worker -n video@myhost -c 3
    celery worker -n data@myhost -c 3

    # ranges and lists of workers in options is also allowed:
    # (-c:1-3 can also be written as -c:1,2,3)
    $ celery multi start 5 -c 3  -c:1-3 10
    celery worker -n celery1@myhost -c 10
    celery worker -n celery2@myhost -c 10
    celery worker -n celery3@myhost -c 10
    celery worker -n celery4@myhost -c 3
    celery worker -n celery5@myhost -c 3

    # lists also works with named workers
    $ celery multi start foo bar baz xuzzy -c 3 -c:foo,bar,baz 10
    celery worker -n foo@myhost -c 10
    celery worker -n bar@myhost -c 10
    celery worker -n baz@myhost -c 10
    celery worker -n xuzzy@myhost -c 3

i    (   t   absolute_importt   print_functiont   unicode_literalsN(   t   defaultdictt
   namedtuple(   t   Popen(   t   sleep(   t   cached_property(   t   OrderedDict(   t	   from_utf8(   t   VERSION_BANNER(   t   items(   t   Pidfilet
   IS_WINDOWS(   t   termt	   nodesplit(   t	   pluralizeu	   MultiToolc         c@ s0   |  ]& } | j  d  ƒ r d | k r | Vq d S(   u   SIGu   _N(   t
   startswith(   t   .0t   sig(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pys	   <genexpr>w   s    c         c@ s$   |  ] } t  t | ƒ | f Vq d  S(   N(   t   getattrt   signal(   R   t   name(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pys	   <genexpr>y   s    u  usage: {prog_name} start <node1 node2 nodeN|range> [worker options]
       {prog_name} stop <n1 n2 nN|range> [-SIG (default: -TERM)]
       {prog_name} stopwait <n1 n2 nN|range> [-SIG (default: -TERM)]
       {prog_name} restart <n1 n2 nN|range> [-SIG] [worker options]
       {prog_name} kill <n1 n2 nN|range>

       {prog_name} show <n1 n2 nN|range> [worker options]
       {prog_name} get hostname <n1 n2 nN|range> [-qv] [worker options]
       {prog_name} names <n1 n2 nN|range>
       {prog_name} expand template <n1 n2 nN|range>
       {prog_name} help

additional options (must appear after command name):

    * --nosplash:   Don't display program info.
    * --quiet:      Don't show as much output.
    * --verbose:    Show more output.
    * --no-color:   Don't display colors.
u   multi_args_tu   nameu   argvu   expanderu	   namespacec           C@ s    t  j t ƒ  j t  j ƒ ƒ d  S(   N(   t   syst   exitt	   MultiToolt   execute_from_commandlinet   argv(    (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   main•   s    u   celeryi   i   u   celery.__main__c          G@ s   d j  t f |  ƒ S(   Nu    (   t   joint
   CELERY_EXE(   t   args(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt
   celery_exeŸ   s    R   c        	   B@ s‘  e  Z d  Z d  d  e e e e d  d  d „ Z d d „ Z e d  d „ Z e d  d „ Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z e j d  d  d „ Z d  d „ Z d „  Z d  d  d „ Z d  d  d „ Z d „  Z d „  Z e Z d  d „ Z d  d „ Z d „  Z d „  Z e j  d „ Z! d  d „ Z" e d „ Z# e d „ Z$ e% d „  ƒ Z& e% d „  ƒ Z' e% d „  ƒ Z( e% d „  ƒ Z) RS(!   i    c	   	      C@ sâ   | p | p t  j |  _ |  _ | p+ t  j |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d |  _	 i |  j
 d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d	 6|  j d
 6|  j d 6|  j d 6|  _ d S(   u   fh is an old alias to stdout.u   celery multiu   startu   showu   stopu   stopwaitu   stop_verifyu   restartu   killu   namesu   expandu   getu   helpN(   R   t   stdoutt   fht   stderrt   envt   nosplasht   quiett   verboset   no_colort	   prog_namet   startt   showt   stopt   stopwaitt   restartt   killt   namest   expandt   gett   helpt   commands(	   t   selfR$   R"   R&   R'   R(   R%   R!   R#   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   __init__¦   s&    						








u   celery workerc         C@ sv  t  | ƒ } d | k r6 | j | j d ƒ ƒ |  _ n  d | k r` | j | j d ƒ ƒ |  _ n  d | k rŠ | j | j d ƒ ƒ |  _ n  d | k r´ | j | j d ƒ ƒ |  _ n  d | k rÞ | j | j d ƒ ƒ |  _ n  t j j	 | j d ƒ ƒ |  _
 | s| d d d k r!|  j ƒ  Sy  |  j | d | d | ƒ Wn+ t k
 rn|  j d	 j | d ƒ ƒ n X|  j S(
   Nu
   --nosplashu   --quietu   -qu	   --verboseu
   --no-colori    u   -i   u   Invalid command: {0}(   t   listt   popt   indexR%   R&   R'   R(   t   ost   patht   basenameR)   t   errorR4   t   KeyErrort   formatt   retcode(   R5   R   t   cmd(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR   ½   s&    
 c         C@ s/   t  | d | p |  j d | r$ d n d ƒd  S(   Nt   filet   endu   
u    (   t   printR!   (   R5   t   mt   newlineRB   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   say×   s    c         C@ s   |  j  | | | p |  j ƒ S(   N(   RG   R#   (   R5   RE   RF   RB   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   carpÚ   s    c         C@ s9   t  | ƒ } |  j d j d „  t | | ƒ Dƒ ƒ ƒ d  S(   Nu   
c         s@ s   |  ] } | j  Vq d  S(   N(   R   (   R   t   n(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pys	   <genexpr>à   s    (   t   NamespacedOptionParserRG   R   t
   multi_args(   R5   R   RA   t   p(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR0   Ý   s    c         C@ sd   | d } t  | d ƒ } xC t | | ƒ D]2 } | j | k r* |  j d j | j ƒ ƒ d  Sq* Wd  S(   Ni    i   u    (   RJ   RK   R   RG   R   R   (   R5   R   RA   t   wantedRL   t   node(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR2   ã   s    
c         C@ sF   t  | ƒ } |  j | ƒ |  j d j d „  t | | ƒ Dƒ ƒ ƒ d  S(   Nu   
c         s@ s+   |  ]! } d  j  t j g | j ƒ Vq d S(   u    N(   R   R   t
   executableR   (   R   RI   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pys	   <genexpr>ï   s    (   RJ   t   with_detacher_default_optionsRG   R   RK   (   R5   R   RA   RL   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR+   ë   s    c         C@ sÓ   |  j  ƒ  t | ƒ } |  j | ƒ g  } |  j d ƒ x t | | ƒ D]p } |  j d j | j ƒ d t ƒ|  j | j	 d | j
 d ƒ} |  j | rŸ |  j p¥ |  j ƒ | j | ƒ qF Wt t | ƒ ƒ |  _ d  S(   Nu   > Starting nodes...u   	> {0}: RF   R;   u   --executable(   t   splashRJ   RP   t   noteRK   R?   R   t   Falset   waitexecR   t   optionst   FAILEDt   OKt   appendt   intt   anyR@   (   R5   R   RA   RL   t   retcodesRN   R@   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR*   ò   s    
c         C@ st   t  | j d d g d ƒ t  | j d d g d ƒ | j j d d j t d	 d
 ƒ ƒ ƒ t  | j d g t j ƒ d  S(   Nu	   --pidfileu   -pu   %N.pidu	   --logfileu   -fu   %N.logu   --cmdu   -m {0}u   workeru   --detachu   --executable(   t   _setdefaultoptRU   t
   setdefaultR?   R    R   RO   (   R5   RL   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRP   ÿ   s    	c         C@ s`   y t  j | | ƒ WnE t k
 r[ } | j t j k r> ‚  n  |  j d j | | ƒ ƒ t SXt S(   Nu+   Could not signal {0} ({1}): No such process(	   R:   R/   t   OSErrort   errnot   ESRCHRR   R?   RS   t   True(   R5   t   nodenamet   pidR   t   exc(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   signal_node  s    c         C@ sG   y t  j | d ƒ Wn, t k
 rB } | j t j k r< t S‚  n Xt S(   Ni    (   R:   R/   R^   R_   R`   RS   Ra   (   R5   Rc   Rd   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt
   node_alive  s    c         @ s©  | s
 d  St  | ƒ ‰  ‡  ‡ f d †  } ˆ j ˆ j j d ƒ ƒ xx t ˆ  ƒ D]j } | ˆ  k rN | \ } } }	 ˆ j d j | t | d |	 ƒ ƒ ˆ j | |	 | ƒ s¸ | | ƒ q¸ qN qN W‡  ‡ f d †  }
 | r¥|
 ƒ  d } x± ˆ  r”xz ˆ  D]r } | d 7} ˆ j d d	 t ƒ| \ } } }	 ˆ j	 |	 ƒ sñ ˆ j d
 j | ˆ j
 ƒ ƒ | | ƒ |
 ƒ  Pqñ qñ Wˆ  rä | t ˆ  ƒ rä t t | ƒ ƒ qä qä Wˆ j d ƒ n  d  S(   Nc         @ s$   ˆ  j  |  ƒ ˆ r  ˆ |  Œ  n  d  S(   N(   t   discard(   RN   (   t   Pt   callback(    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   on_down"  s    u   > Stopping nodes...u   	> {0}: {1} -> {2}i   c          @ si   t  ˆ  ƒ }  |  re d j d „  ˆ  Dƒ ƒ } ˆ j ˆ j j d j |  t |  d ƒ | ƒ ƒ d t ƒn  d  S(   Nu   , c         s@ s$   |  ] \ } } } t  | ƒ Vq d  S(   N(   t   str(   R   t   _Rc   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pys	   <genexpr>3  s    u   > Waiting for {0} {1} -> {2}...u   nodeRF   (   t   lenR   RR   t   coloredt   blueR?   R   RS   (   t   leftt   pids(   Rh   R5   (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   note_waiting0  s    i    i   u   .RF   u   
	> {0}: {1}u    (   t   setRR   Rn   Ro   R7   R?   t   SIGMAPRe   RS   Rf   RW   Rm   R   t   float(   R5   t   nodesR   t   retryRi   Rj   RN   Rb   Rl   Rc   Rr   t   its(    (   Rh   Ri   R5   s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   shutdown_nodes  s:    	

c   	      C@ s1  t  | j d d g d ƒ g  } xt | | ƒ D]ú } y# t | j | j d d g ƒ } Wn) t k
 rƒ t | j d d g ƒ } n Xd  } | j | ƒ } y t	 | ƒ j
 ƒ  } Wn t k
 rÂ n X| rî | j | j t | j ƒ | f ƒ q/ |  j d j | |  j ƒ ƒ | r/ | | j | j | ƒ q/ q/ W| S(   Nu	   --pidfileu   -pu   %N.pidu   > {0.name}: {1}(   R\   RU   RK   t   _getoptt
   namespacest	   namespaceR>   t   Nonet   expanderR   t   read_pidt
   ValueErrorRX   R   t   tupleR   RR   R?   t   DOWN(	   R5   RL   RA   Ri   Rv   RN   t   pidfile_templateRc   t   pidfile(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   getpidsI  s(     %c         C@ so   |  j  ƒ  t | ƒ } xR |  j | | ƒ D]> \ } } } |  j d j | | ƒ ƒ |  j | | t j ƒ q) Wd  S(   Nu   Killing node {0} ({1})(   RQ   RJ   R…   RR   R?   Re   R   t   SIGKILL(   R5   R   RA   RL   Rb   Rl   Rc   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR/   c  s
    
"c         C@ s2   |  j  ƒ  t | ƒ } |  j | | d | d | ƒS(   NRw   Ri   (   RQ   RJ   t   _stop_nodes(   R5   R   RA   Rw   Ri   RL   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR,   j  s    
c         C@ sQ   | j  t | j ƒ } |  j |  j | | d | ƒd t | ƒ d | d | ƒd  S(   NRi   R   Rw   (   R   Rm   t   valuesRy   R…   t   findsig(   R5   RL   RA   Rw   Ri   t   restargs(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR‡   o  s
    c         @ ss   ˆ j  ƒ  t | ƒ ‰  ˆ j ˆ  ƒ g  ‰ ‡  ‡ ‡ f d †  } ˆ j ˆ  | d d d | ƒt t ˆ ƒ ƒ ˆ _ d  S(   Nc         @ st   ˆ j  ˆ j j d j |  ƒ ƒ d t ƒˆ j | d ˆ  j d ƒ} ˆ j  | rY ˆ j p_ ˆ j ƒ ˆ j	 | ƒ d  S(   Nu   > Restarting node {0}: RF   R;   u   --executable(
   RR   Rn   Ro   R?   RS   RT   RU   RV   RW   RX   (   Rb   R   Rc   t   retval(   RL   t   retvalsR5   (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   on_node_shutdown|  s
    Rw   i   Ri   (   RQ   RJ   RP   R‡   RY   RZ   R‹   (   R5   R   RA   R   (    (   RL   RŒ   R5   s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR.   v  s    
c         C@ s9   |  j  ƒ  t | ƒ } |  j | ƒ |  j | | d d ƒS(   NRw   i   (   RQ   RJ   RP   R‡   (   R5   R   RA   RL   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR-   †  s    
c         C@ sN   | d } t  | d ƒ } x- t | | ƒ D] } |  j | j | ƒ ƒ q* Wd  S(   Ni    i   (   RJ   RK   RG   R~   (   R5   R   RA   t   templateRL   RN   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR1     s    
c         C@ s   |  j  t ƒ d  S(   N(   RG   t   __doc__(   R5   R   RA   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR3   “  s    c         C@ s*   |  j  ƒ  |  j t j d |  j ƒ ƒ d  S(   NR)   (   RQ   RG   t   USAGER?   R)   (   R5   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   usage–  s    
c         C@ s8   |  j  s4 |  j } |  j | j d j t ƒ ƒ ƒ n  d  S(   Nu   celery multi v{0}(   R%   Rn   RR   t   cyanR?   R
   (   R5   t   c(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRQ   š  s    		c         C@ sÉ   d j  | g t | ƒ ƒ } t j t | ƒ d t ƒ} t | d |  j ƒ} |  j d j	 d j  | ƒ ƒ ƒ | j
 ƒ  } | d k  r  |  j d j	 | ƒ ƒ | S| d k rÅ |  j d j	 | ƒ ƒ n  | S(   Nu    t   posixR$   u     {0}i    u$   * Child was terminated by signal {0}u%   * Child terminated with errorcode {0}(   R   R7   t   shlext   splitR	   R   R   R$   t   infoR?   t   waitRR   (   R5   R   R;   R   t   argstrt   pipeR@   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRT   Ÿ  s    c         C@ s-   | r |  j  | ƒ n  |  j ƒ  d |  _ d S(   Ni   (   RH   R‘   R@   (   R5   t   msg(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR=   ¬  s
    
	c         C@ s#   |  j  r |  j | d | ƒn  d  S(   NRF   (   R'   RR   (   R5   R›   RF   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR—   ³  s    	c         C@ s)   |  j  s% |  j t | ƒ d | ƒn  d  S(   NRF   (   R&   RG   Rk   (   R5   R›   RF   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRR   ·  s    	c         C@ s   t  j d |  j ƒ S(   Nt   enabled(   R   Rn   R(   (   R5   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRn   »  s    c         C@ s   t  |  j j d ƒ ƒ S(   Nu   OK(   Rk   Rn   t   green(   R5   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRW   ¿  s    c         C@ s   t  |  j j d ƒ ƒ S(   Nu   FAILED(   Rk   Rn   t   red(   R5   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRV   Ã  s    c         C@ s   t  |  j j d ƒ ƒ S(   Nu   DOWN(   Rk   Rn   t   magenta(   R5   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR‚   Ç  s    N(*   t   __name__t
   __module__R@   R}   RS   R6   R   Ra   RG   RH   R0   R2   R+   R*   RP   Re   Rf   R   t   SIGTERMRy   R…   R/   R,   R‡   R.   R-   t   stop_verifyR1   R3   R‘   RQ   R   RO   RT   R=   R—   RR   R   Rn   RW   RV   R‚   (    (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR   £   sD   										,					u   celery workeru    c         c@ sv  |  j  } t |  j ƒ } |  j } t | ƒ d k } | r– y t | d ƒ }	 Wn t k
 r` q– Xg  t d |	 d ƒ D] }
 t |
 ƒ ^ qu } d } n  | j	 d | ƒ } | j	 d | ƒ } | j	 d | j	 d t
 j ƒ  ƒ ƒ } | j	 d | ƒ pó d	 } | j	 d
 | ƒ p| } | d k r#d	 } n  x‚ t t |  j ƒ ƒ D]k \ } } d | k sc| r9d | k r9x+ t | | ƒ D] } |  j | j | ƒ qsW|  j j	 | ƒ q9q9Wx§ t t |  j ƒ ƒ D] \ } } | j ƒ  r¾t | ƒ d } | d k  rt d | f ƒ ‚ n  y |  j | | j | ƒ WqNt k
 rJt d | f ƒ ‚ qNXq¾q¾Wx| D]} | } d | k rš| } | d <t | ƒ \ } } | } n( d | | f } d | | f } | d <t i | d 6| d 6| d 6| d 6ƒ } | | ƒ g g  t |  j | | ƒ ƒ D]! \ } } t | | | ƒ ƒ ^ q| g } | rZ| j | | ƒ ƒ n  t | | | | ƒ VqYWd  S(   Ni   i    u   celeryu   --cmdu   --appendu
   --hostnameu   -nu   --prefixu    u   --suffixu   ""u   ''u   ,u   -u   Indexes start at 1 got: %ru   No node at index %ru   @u   %s%su   %s@%su   %hu   %nu   %Nu   %d(   u   ""u   ''(   Rˆ   t   dictRU   t   passthroughRm   RY   R€   t   rangeRk   R8   t   sockett   gethostnameR7   R   R{   t   parse_ns_ranget   updatet   isdigitR>   t
   IndexErrorR   t   abbreviationst   optmerget
   format_optRX   t   multi_args_t(   RL   RA   RX   t   prefixt   suffixR0   RU   R¥   t   rangest	   noderangeRI   t   hostnamet   ns_namet   ns_optst   subnst   ns_indexR   t   this_suffixt	   this_nameRb   R1   t   optt   valueR   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRK   Ì  sd    		,			""	J
RJ   c           B@ sM   e  Z d  „  Z d „  Z d d „ Z d d „ Z d d „ Z e d d „ Z	 RS(   c         C@ sG   | |  _  t ƒ  |  _ g  |  _ d |  _ t d „  ƒ |  _ |  j ƒ  d  S(   Nu    c           S@ s   t  ƒ  S(   N(   R   (    (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   <lambda>  t    (   R   R   RU   Rˆ   R¥   R   R{   t   parse(   R5   R   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR6     s    			c         C@ s  t  |  j ƒ } d } xú | t | ƒ k  r| | } | d k rZ d j | | ƒ |  _ Pnª | d d k rô | d d k rŽ |  j | d ƒ qd  } t | ƒ | d k rÝ | | d d d k rÝ | | d } | d 7} n  |  j | d | ƒ n |  j j	 | ƒ | d 7} q Wd  S(   Ni    u   --u    u   -i   i   (
   R7   R   Rm   R   R¥   t   process_long_optR}   t   process_short_optRˆ   RX   (   R5   t   rargst   post   argR½   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRÀ     s"    
.c         C@ sA   d | k r' | j  d d ƒ \ } } n  |  j | | d t ƒd  S(   Nu   =i   t   short(   R–   t
   add_optionRS   (   R5   RÅ   R½   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRÁ   *  s    c         C@ s   |  j  | | d t ƒd  S(   NRÆ   (   RÇ   Ra   (   R5   RÅ   R½   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRÂ   /  s    c         C@ s,   | d  k r |  j } n  t | |  j |  S(   N(   R}   RU   R   R{   (   R5   t   nst   defaults(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR®   2  s    c         C@ s^   | r d p d } |  j  } d | k rL | j d ƒ \ } } |  j | } n  | | | | <d  S(   Nu   -u   --u   :(   RU   R–   R{   (   R5   R   R½   RÆ   RÈ   R±   t   dest(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRÇ   7  s    	N(
   R    R¡   R6   RÀ   R}   RÁ   RÂ   R®   RS   RÇ   (    (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRJ   
  s   			c         C@ s    d j  d „  |  j d ƒ Dƒ ƒ S(   Nu   \'c         s@ s   |  ] } d  | d  Vq d S(   u   'N(    (   R   RL   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pys	   <genexpr>A  s    u   '(   R   R–   (   t   v(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   quote@  s    c         C@ s9   | s
 |  S|  j  d ƒ r) d j |  | ƒ Sd j |  | ƒ S(   Nu   --u   {0}={1}u   {0} {1}(   R   R?   (   R¼   R½   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR¯   D  s
    c         C@ s    g  } x“ d |  k r$ |  j  d ƒ p* |  g D]m } | r‹ d | k r‹ | j  d ƒ \ } } | j d „  t t | ƒ t | ƒ d ƒ Dƒ ƒ q+ | j | ƒ q+ W| S(   Nu   ,u   -c         s@ s   |  ] } t  | ƒ Vq d  S(   N(   Rk   (   R   RI   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pys	   <genexpr>R  s    i   (   R–   t   extendR¦   RY   RX   (   RÈ   R³   t   rett   spaceR*   R,   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR©   L  s    +-c         @ s   ‡  f d †  } | S(   Nc         @ sH   |  } |  d  k	 rD x/ t ˆ  ƒ D] \ } } | j | | ƒ } q Wn  | S(   N(   R}   R   t   replace(   t   SRÎ   t	   short_optt   long_opt(   t   mapping(    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR1   [  s
    (    (   RÔ   R1   (    (   RÔ   s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR­   Y  s    c         C@ s    x™ t  |  ƒ D]‹ } t | ƒ d k r^ | d d k r^ y t | d ƒ SWq^ t k
 rZ q^ Xn  | d d k r d | d } | t k r˜ t t | ƒ Sq q W| S(   Ni   i    u   -i   u   SIG(   t   reversedRm   RY   R€   t   SIGNAMESR   R   (   R   t   defaultRÅ   t	   maybe_sig(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR‰   e  s    "c         C@ sE   x. | D]& } y |  | SWq t  k
 r, q Xq Wt  | d ƒ ‚ d  S(   Ni    (   R>   (   t   dt   altR¼   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyRz   s  s    c         C@ sI   x2 | d D]& } y |  | SWq t  k
 r0 q Xq W|  j | d | ƒ S(   Ni   i    (   R>   R]   (   RÙ   RÚ   R½   R¼   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyR\   |  s    u   __main__(>   R   t
   __future__R    R   R   R_   R:   R•   R   R§   R   t   collectionsR   R   t
   subprocessR   t   timeR   t   kombu.utilsR   t   kombu.utils.compatR   t   kombu.utils.encodingR	   t   celeryR
   t   celery.fiveR   t   celery.platformsR   R   t   celery.utilsR   R   t   celery.utils.textR   t   __all__Rs   t   dirRÖ   R¤   Rt   R   R°   R   R   t   version_infoR    t   objectR   RK   RJ   RÌ   R¯   RS   R©   R­   R¢   R‰   Rz   R\   R    (    (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/bin/multi.pyt   <module>]   sT   				ÿ *>6							