o
    wvXj   ã                   @   sX   d 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 G dd„ deƒZd	S )
zEThe ``celery call`` program used to send tasks from the command-line.é    )Úabsolute_importÚunicode_literals)Úloads)ÚCommand)Ústring_t)Úmaybe_iso8601c                   @   s:   e Zd ZdZdZdZdd„ Zdd„ Z				dd	d
„ZdS )ÚcallzÀCall a task by name.

    Examples:
        .. code-block:: console

            $ celery call tasks.add --args='[2, 2]'
            $ celery call tasks.add --args='[2, 2]' --countdown=10
    z<task_name>Úposargsc                 C   s¢   |  d¡}|jdddd� |jdddd� |jd	d
d� |jdtdd� |jddd�f |jdddd�f |  d¡}|jddd� |jddd� |jddd� d S )NzCalling Optionsz--argsz-azpositional arguments (json).)Úhelpz--kwargsz-kzkeyword arguments (json).z--etazscheduled time (ISO-8601).z--countdownz$eta in seconds from now (float/int).)Útyper
   z	--expiresz!expiry time (ISO-8601/float/int).z--serializerÚjsonzdefaults to json.)Údefaultr
   zRouting Optionsz--queuezcustom queue name.z
--exchangezcustom exchange name.z--routing-keyzcustom routing key.)Úadd_argument_groupÚadd_argumentÚfloat)ÚselfÚparserÚgroupÚropts© r   úL/var/www/html/myproject/venv/lib/python3.10/site-packages/celery/bin/call.pyÚadd_arguments   s4   
ÿÿÿþþþ
zcall.add_argumentsc                 O   s   | j |fi |¤Ž d S )N)Ú
_send_task)r   ÚnameÚ_Úkwargsr   r   r   Úrun3   s   zcall.runNc                 K   sª   t |tƒr	t|ƒn|}t |tƒrt|ƒn|}zt|
ƒ}
W n ttfy8   zt|
ƒ}
W n
 ttfy5   ‚ w Y nw |  | jj	||pBd|pEi |||||t|	ƒ|
d�
j
¡ d S )Nr   )	Úargsr   Ú	countdownÚ
serializerÚqueueÚexchangeÚrouting_keyÚetaÚexpires)Ú
isinstancer   r   r   Ú	TypeErrorÚ
ValueErrorr   ÚoutÚappÚ	send_taskÚid)r   r   r   r   r   r   r    r!   r"   r#   r$   r   r   r   r   r   6   s2   ÿÿý
÷
özcall._send_task)	NNNNNNNNN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú	args_namer   r   r   r   r   r   r   r      s    	ýr   N)r/   Ú
__future__r   r   Úkombu.utils.jsonr   Úcelery.bin.baser   Úcelery.fiver   Úcelery.utils.timer   r   r   r   r   r   Ú<module>   s    