
    3~h/                     p    d dl Z d dlZd dlmZmZmZ d Z G d de      Z G d de      Z	 G d d	e      Zy)
    N)Runnerpty_sizeResultc                  v    t        t        d      xr( t        j                         t        j                         u S )NSIGWINCH)hasattrsignal	threadingcurrent_threadmain_thread     W/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/fabric/runners.pycares_about_SIGWINCHr      s1    
# 	B$$&)*?*?*AAr   c                        e Zd ZdZ fdZddZd Z fdZd Zd Z	d Z
d	 Zed
        Zd Zd Zd Z fdZd Zd Z xZS )RemoteaN  
    Run a shell command over an SSH connection.

    This class subclasses `invoke.runners.Runner`; please see its documentation
    for most public API details.

    .. note::
        `.Remote`'s ``__init__`` method expects a `.Connection` (or subclass)
        instance for its ``context`` argument.

    .. versionadded:: 2.0
    c                 R    |j                  dd      | _        t        |   |i | y)aD  
        Thin wrapper for superclass' ``__init__``; please see it for details.

        Additional keyword arguments defined here are listed below.

        :param bool inline_env:
            Whether to 'inline' shell env vars as prefixed parameters, instead
            of trying to submit them via `.Channel.update_environment`.
            Default: ``True``.

        .. versionchanged:: 2.3
            Added the ``inline_env`` parameter.
        .. versionchanged:: 3.0
            Changed the default value of ``inline_env`` from ``False`` to
            ``True``.
        
inline_envN)popr   super__init__)selfargskwargs	__class__s      r   r   zRemote.__init__   s)    " !**\48$)&)r   c           
      Z   | j                   j                         | _        | j                  rbt	               \  }}| j                  j                  ||       t               r.t        j                  t        j                  | j                         |r| j                  r^dj                  t        |j                               D cg c]  \  }}dj                  ||       c}}      }	dj                  |	|      }n| j                  j                  |       | j!                  |       y c c}}w )N)widthheight z{}={}zexport {} && {})contextcreate_sessionchannel	using_ptyr   get_ptyr   r	   r   handle_window_changer   joinsorteditemsformatupdate_environmentsend_start_message)
r   commandshellenvtimeoutcolsrowskv
parameterss
             r   startzRemote.start0   s    ||224>>!JD$LL  tD 9 $%foot/H/HI 
 !XX6<SYY[6IJdaW^^Aq)J
 ,22:wG//4( Ks   D'
c                 :    | j                   j                  |       y N)r"   exec_commandr   r,   s     r   r+   zRemote.send_start_messageN   s    !!'*r   c                 H    |j                  dd       t        |   |fi |S )Nreplace_envT)
setdefaultr   run)r   r,   r   r   s      r   r=   z
Remote.runQ   s'    -.w{7-f--r   c                 8    | j                   j                  |      S r7   )r"   recvr   	num_bytess     r   read_proc_stdoutzRemote.read_proc_stdoutU   s    ||  ++r   c                 8    | j                   j                  |      S r7   )r"   recv_stderrr@   s     r   read_proc_stderrzRemote.read_proc_stderrX   s    ||''	22r   c                 8    | j                   j                  |      S r7   )r"   sendall)r   datas     r   _write_proc_stdinzRemote._write_proc_stdin[   s    ||##D))r   c                 6    | j                   j                         S r7   )r"   shutdown_writer   s    r   close_proc_stdinzRemote.close_proc_stdin^   s    ||**,,r   c                 6    | j                   j                         S r7   )r"   exit_status_readyrL   s    r   process_is_finishedzRemote.process_is_finisheda   s    ||--//r   c                 V    | j                   r| j                  j                  d       y |)N)r#   r"   send)r   	interrupts     r   send_interruptzRemote.send_interrupte   s$     >> LLf%Or   c                 6    | j                   j                         S r7   )r"   recv_exit_statusrL   s    r   
returncodezRemote.returncodeu   s    ||,,..r   c                 6    | j                   |d<   t        di |S N
connectionr   )r    r   )r   r   s     r   generate_resultzRemote.generate_resultx   s    #|||r   c                     t         |           t        | d      r| j                  j	                          t               r3t        j                  t        j                  t        j                         y y )Nr"   )	r   stopr   r"   closer   r	   r   SIG_DFL)r   r   s    r   r^   zRemote.stop|   sG    4#LL !MM&//6>>: "r   c                 8    | j                   j                          y r7   )r"   r_   rL   s    r   killzRemote.kill   s     	r   c                 F     | j                   j                  t                 y)z
        Respond to a `signal.SIGWINCH` (as a standard signal handler).

        Sends a window resize command via Paramiko channel method.
        N)r"   
resize_ptyr   )r   signumframes      r   r%   zRemote.handle_window_change   s     	 ,r   r7   )__name__
__module____qualname____doc__r   r5   r+   r=   rB   rE   rI   rM   propertyrP   rU   rX   r\   r^   rb   r%   __classcell__r   s   @r   r   r      sb    *()<+.,3*- 0 0 / ;-r   r   c                       e Zd Zd Zy)RemoteShellc                 8    | j                   j                          y r7   )r"   invoke_shellr9   s     r   r+   zRemoteShell.send_start_message   s    !!#r   N)rg   rh   ri   r+   r   r   r   ro   ro      s    $r   ro   c                   "     e Zd ZdZ fdZ xZS )r   a  
    An `invoke.runners.Result` exposing which `.Connection` was run against.

    Exposes all attributes from its superclass, then adds a ``.connection``,
    which is simply a reference to the `.Connection` whose method yielded this
    result.

    .. versionadded:: 2.0
    c                 T    |j                  d      }t        |   di | || _        y rZ   )r   r   r   r[   )r   r   r[   r   s      r   r   zResult.__init__   s(    ZZ-
"6"$r   )rg   rh   ri   rj   r   rl   rm   s   @r   r   r      s    % %r   r   )
r	   r
   invoker   r   r   InvokeResultr   r   ro   r   r   r   <module>rv      s=      ; ;C-V C-r$& $
%\ %r   