o
    ›¨Êhç  ã                   @   s2  d Z ddlZddlZddlmZ ddlZddlmZmZm	Z	 dd„ Z
dd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zejeddid�ejdddeddd�ejdd dedd!d�ejd"dedd#d�ejd$d%dedd&d�ejd'dedd(d�ejd)dedd*d�eje		+	+	+d.d,d-„ƒƒƒƒƒƒƒƒƒZdS )/z3The ``celery shell`` program, used to start a REPL.é    N)Úimport_module)ÚCeleryCommandÚCeleryOptionÚhandle_preload_optionsc                 C   s\   dd l }zdd l}W n	 ty   Y nw dd l}| | | ¡j¡ | d¡ |j| d� d S )Nr   ztab:complete)Úlocal)	ÚcodeÚreadlineÚImportErrorÚrlcompleterÚset_completerÚ	CompleterÚcompleteÚparse_and_bindÚinteract)Úlocalsr   r   r
   © r   úB/var/www/html/env/lib/python3.10/site-packages/celery/bin/shell.pyÚ_invoke_fallback_shell   s   ÿ
ÿ
r   c                 C   s   dd l }| | ¡ d S ©Nr   )ÚbpythonÚembed)r   r   r   r   r   Ú_invoke_bpython_shell   s   r   c              	   C   s8   t ttttfD ]}z|| ƒW   S  ty   Y qw d S )N)Ú_ipythonÚ_ipython_pre_10Ú_ipython_terminalÚ_ipython_010Ú_no_ipythonr	   )r   Úipr   r   r   Ú_invoke_ipython_shell   s   þÿûr   c                 C   s   ddl m} |g | d� d S )Nr   )Ústart_ipython©ÚargvÚuser_ns)ÚIPythonr   )r   r   r   r   r   r   )   s   r   c                 C   s:   ddl m} | ¡ }|jg d� |jj | ¡ | ¡  d S )Nr   )ÚTerminalIPythonApp)r!   )ÚIPython.frontend.terminal.ipappr$   ÚinstanceÚ
initializeÚshellr"   ÚupdateÚstart)r   r$   Úappr   r   r   r   .   s
   r   c                 C   s    ddl m} |j| d� ¡  d S )Nr   )r   )r"   )ÚIPython.terminalr   ÚTerminalInteractiveShellÚmainloop)r   r   r   r   r   r   6   ó   r   c                 C   s    ddl m} |g | d� ¡  d S )Nr   )ÚIPShellr    )ÚIPython.Shellr0   r.   )r   r0   r   r   r   r   ;   r/   r   c                 C   s   t dƒ‚)Nzno suitable ipython found)r	   )Úselfr   r   r   r   @   s   r   c                 C   sb   zdd l }W n$ ty*   zdd l}W n ty"   t| ƒ Y Y d S w t| ƒ Y d S w t| ƒ d S r   )r#   r	   r   r   r   r   )r   r#   r   r   r   r   Ú_invoke_default_shellD   s   ÿúr3   Úallow_extra_argsT)ÚclsÚcontext_settingsz-Iz	--ipythonzShell OptionszForce IPython.)Úis_flagr5   Ú
help_groupÚhelpz-Bz	--bpythonzForce bpython.z--pythonzForce default Python shell.z-Tz--without-taskszDon't add tasks to locals.z
--eventletzUse eventlet.z--geventzUse gevent.Fc                 K   s4  t j dt ¡ ¡ |rtdƒ |rtdƒ ddl}| jj}	|	j	 
¡  |	|	|j|j|j|j|j|j|j|j|jdœ}
|sH|
 dd„ |	j ¡ D ƒ¡ |rOt|
ƒ nE|rlzt|
ƒ W n< tyk   | j | jj› d�¡ Y n)w |r”zt|
ƒ W n ty“ } z| j | jj› d	|› �¡ W Y d}~nd}~ww t|
ƒ dS )
a.  Start shell session with convenient access to celery symbols.

    The following symbols will be added to the main globals:
    - ``celery``:  the current application.
    - ``chord``, ``group``, ``chain``, ``chunks``,
      ``xmap``, ``xstarmap`` ``subtask``, ``Task``
    - all registered tasks.
    r   zcelery.concurrency.eventletzcelery.concurrency.geventN)r+   ÚceleryÚTaskÚchordÚgroupÚchainÚchunksÚxmapÚxstarmapÚsubtaskÚ	signaturec                 S   s    i | ]}|j  d ¡s|j|“qS )zcelery.)ÚnameÚ
startswithÚ__name__)Ú.0Útaskr   r   r   Ú
<dictcomp>œ   s    
þÿzshell.<locals>.<dictcomp>z: bpython is not installedz: )ÚsysÚpathÚinsertÚosÚgetcwdr   r:   Úobjr+   ÚloaderÚimport_default_modulesr;   r<   r=   r>   r?   r@   rA   rB   rC   r)   ÚtasksÚvaluesr   r   r	   ÚechoÚERRORr   r3   )ÚctxÚipythonr   ÚpythonÚwithout_tasksÚeventletÚgeventÚkwargsr:   r+   r   Úer   r   r   r(   R   sP   1
õ
ÿ
ÿ&€ÿr(   )FFFFFF)Ú__doc__rM   rJ   Ú	importlibr   ÚclickÚcelery.bin.baser   r   r   r   r   r   r   r   r   r   r   r3   ÚcommandÚoptionÚpass_contextr(   r   r   r   r   Ú<module>   s~    
ÿûûüûüü þ