
    h!                     P   d Z ddlmZ ddlmZ ddlZddlmZ ddlm	Z	m
Z
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Zd Zd Zed   ZdededdfdZdefdZdedefdZ ej<                  e
       ej>                  ddee ddd       ej>                  ddee	dd       ej>                  d d!ed"dd#$      ejB                  ed%                                           Z" ej<                  e
d&d"i'       ejF                  d       ed(       ej>                  ddee ddd       ej>                  ddee	dd       ej>                  d d!ed"dd#$      ejB                  ed)                                                         Z$ ej<                  e
d&d"i'       ejF                  d       ed*       ej>                  ddee ddd       ej>                  ddee	dd       ej>                  d d!ed"dd#$      ejB                  ed+                                                         Z%y)-z@The ``celery control``, ``. inspect`` and ``. status`` programs.    )partial)LiteralN)dumps)COMMA_SEPARATED_LISTCeleryCommandCeleryOptionhandle_preload_options)CeleryCommandException)EX_UNAVAILABLE)text)Panelc                 *   t        t        |            }||   }| j                  j                  | ddd      }| j                  j	                  |      \  }}| j                  j                  d| | |rt        j                  |d      nd|       y )	Nz: cyanT)fgboldz->    )	show_body)nextiterobjstyleprettysay_chatr   indent)ctxreplies
show_replynodereplystatuspreplys          N/var/www/Befach/backend/env/lib/python3.12/site-packages/celery/bin/control.py_say_remote_command_replyr$      s    WDDME77==D6d=;DWW^^E*NFFGGTdVF8,/9T[[+r)  +    c              #   >  K   d}	 t        |      D ](  \  }}	 | j                  |   \  }}|| ||      n|f * ||d  |d d  y # t        $ r? | j                  rY  !t	        j
                  dj                  || j                              w xY w# ||d  |d d  w xY ww)Nr   z Command {!r} takes arguments: {})	enumerateargs
IndexErrorvariadicclick
UsageErrorformat	signature)metamethodr(   iargnametyps          r#   _consume_argumentsr5      s     	AoFAs	A IIaL	c CHS@@ & qr(Q  1==&&6==01 11 qr(Qs=   BB AB 	BBB 0BB 
BBc                    t         j                  |    }i }|j                  r0|j                  t	        || |      D ci c]  \  }}||
 c}}       |j
                  r|j                  |j
                  |i       |S c c}}w N)r   r/   r(   updater5   r*   )commandr(   r/   	argumentskvs         r#   _compile_argumentsr=   +   sy    ::gDIyy/gtD
QAqD
 	 }}$--./
s   A=
)inspectcontroltype_r9   returnc                     t        |       }||vr0dj                  |      }t        j                  d| d|  d|       y )Nz, zCommand z not recognized. Available z commands: )message)_get_commands_of_typejoinr+   r,   )r@   r9   choicescommand_listings       r#   _verify_command_namerH   :   sS    #E*Gg))G,wi'B5'UdTef
 	
 r%   c                 r     dt         j                  dd f fd}t        j                  ddd  ddd|	      S )
Nr   rA   c                    |sy t        	      }t        j                         }|j                  	j	                          d      5  g }|j                         D ]B  \  }}|j                  r| d|j                   }n|}|j                  ||j                  f       D |j                  |       d d d        | j                  j                  |j                         d       | j                          y # 1 sw Y   ExY w)Nz	 Commands F)nl)rD   r+   HelpFormattersection
capitalizeitemsr.   appendhelpwrite_dlr   echogetvalueexit)
r   paramvaluerF   	formattercommand_listcommand_nameinfocommand_previewr@   s
            r#   callbackz_list_option.<locals>.callbackE   s    '.'')	%"2"2"4!5Y?@ 	-L&-mmo"d>>)5a7G&HO&2O##_dii$@A '6 |,	- 	Y'')e4
	- 	-s   A)C33C<z--listTzList available z commands and exit.F)is_flagrR   expose_valueis_eagerr^   )r+   Contextoption)r@   r^   s   ` r#   _list_optionrd   D   sI    emm d & <<ug%89 r%   c                     t         j                  j                         D cg c]$  \  }}|j                  | k(  r|j                  r||f& }}}t        t        |            S c c}}w r7   )r   r/   rP   typevisibledictsorted)r@   r3   r\   command_name_info_pairss       r#   rD   rD   b   s_    ',zz'7'7'9#t99$,, 
t  ./00	s   )A")clsz-tz	--timeoutg      ?zRemote Control Optionsz%Timeout in seconds waiting for reply.)rk   rf   default
help_grouprR   z-dz--destinationz/Comma separated list of destination node names.)rk   rf   rm   rR   z-jz--jsonTzUse json as output format.)rk   r_   rm   rR   c           	         |rdnt        t        |       }| j                  j                  j                  j                  |||      j                         }|st        dt              |r$| j                  j                  t        |             t        |      }|j                  dd      s@| j                  j                  dj                  |t        j                  |d                   yy)	z%Show list of workers that are online.Ntimeoutdestinationr^   'No nodes replied within time constraintrC   	exit_codequietF
{} {} online.r   )r   r$   r   appr?   r>   pingr
   r   rT   r   lengetr-   r   	pluralize)r   rp   rq   jsonkwargsr^   r   	nodecounts           r#   r!   r!   j   s    0 t)BC!HHggkk!!))'6A3; * ==ATV  $=$
 	

 U7^$GI::gu%&--t~~i8: 	; &r%   allow_extra_args)rk   context_settingsr>   c           	      4   t        d|       |rdnt        t        | d      }t        || j                        }| j
                  j                  j                  j                  |||      } |j                  |fi |}	|	st        dt              |r%| j
                  j                  t        |	             yt        |	      }
| j
                  j                  s@| j
                  j                  dj!                  |
t#        j$                  |
d	                   yy)
z~Inspect the workers by sending them the COMMAND inspect command.

    Availability: RabbitMQ (AMQP) and Redis transports.
    r>   NTr   ro   rr   rs   rv   r   )rH   r   r$   r=   r(   r   rw   r?   r>   _requestr
   r   rT   r   ry   ru   r-   r   r{   )r   r9   rp   rq   r|   r}   r^   r:   r>   r   r~   s              r#   r>   r>      s    < G,t)BC48":H"7CHH5Iggkk!!))'6A3; * =G gw4)4G$=$
 	

 U7^$GI77==&--t~~i8: 	; r%   r?   c                 V   t        d|       |rdnt        t        | d      }| j                  }t	        ||      }| j
                  j                  j                  j                  ||||d|      }|st        dt              |r%| j
                  j                  t        |             yy)zxSend the COMMAND control command to the workers.

    Availability: RabbitMQ (AMQP), Redis, and MongoDB transports.
    r?   NTr   )rp   rq   r^   r    r:   rr   rs   )rH   r   r$   r(   r=   r   rw   r?   	broadcastr
   r   rT   r   )	r   r9   rp   rq   r|   r^   r(   r:   r   s	            r#   r?   r?      s    < G,t)BC48":H88D"7D1Iggkk!!++GW8C5=266?	 , AG $=$
 	

 U7^$ r%   )F)&__doc__	functoolsr   typingr   r+   kombu.utils.jsonr   celery.bin.baser   r   r   r	   celery.exceptionsr
   celery.platformsr   celery.utilsr   celery.worker.controlr   r$   r5   r=   _RemoteControlTypestrrH   rd   rh   rD   r9   rc   floatpass_contextr!   argumentr>   r?    r%   r#   <module>r      s   F    " e e 4 +  '+$	 12 
 2 
S 
T 
* <1!3 1 1 =!d1:< d'1DF d1/1 ;  1F< ",;* =!3T :<	id1:< d'1DF d1/1 ;  1F<  <2;< =!3T :<	id1:< d'1DF d1/1 %  1F<  <2%r%   