404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.135.218.63: ~ $
3

��KYsx�@svddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZyddlZWne
k
r�ddlZYnXddlmZmZddlmZe	jj�Zejd�p�ejd�Zer�dZddlmZnd	Ze	jdd
kZer�dd�Zn(d
d�ZGdd�de�ZGdd�de�Z d\a!a"dd�Z#Gdd�de$�Z%dd�Z&dd�Z'Gdd�de(�Z)Gdd�de)�Z*dS)�N)�STDIN_FILENO�CHILD�)�which�solaris�sunosF)�	_fork_ptyT�cCs
t|g�S)N)�bytes)�i�r� /usr/lib/python3.6/ptyprocess.py�_byte(srcCst|�S)N)�chr)rrrr
r+sc@seZdZdS)�FileNotFoundErrorN)�__name__�
__module__�__qualname__rrrr
r.src@seZdZdS)�TimeoutErrorN)rrrrrrr
r/srcCs�tdk	rtdk	rdSynddlm}m}ytjj�}Wntk
rRtj	j�}YnXt
tj|�d|�}t
tj|�d|�}Wn\tt
tttjfk
r�yddlm}m}||}}Wntk
r�d\}}YnXYnXt|�at|�adS)	zkSet constants _EOF and _INTR.
    
    This avoids doing potentially costly operations on module load.
    Nr)�VEOF�VINTR�)�CEOF�CINTRr	�)r	r)�_EOF�_INTR�termiosrr�sys�	__stdin__�fileno�
ValueError�
__stdout__�ord�	tcgetattr�ImportError�OSError�IOError�errorrrr)rr�fdZintr�eofrrrrr
�_make_eof_intr3s$r+c@seZdZdZdS)�PtyProcessErrorz%Generic error class for this package.N)rrr�__doc__rrrr
r,Tsr,cCsd}ytj|�}WnTtjk
rf}z6|jdtjkrTt|jdd|jd|f���WYdd}~XnX|r�|dtjB|d<n|dtj@|d<ytj|tj	|�WnRtk
r�}z6|jdtjkr�t|jdd|jd|f���WYdd}~XnXdS)Nz,setecho() may not be called on this platformrz%s: %s.rr	)
rr$r(�args�errno�EINVALr'�ECHOZ	tcsetattrZTCSANOW)r)�state�errmsg�attr�errrrr
�_setechoZs r6cCs0ttdd�}tjd||dd�}tj|||�dS)N�
TIOCSWINSZi����HHHHrigt�)�getattrr�struct�pack�fcntl�ioctl)r)�rows�colsr7�srrr
�_setwinsizersrAc@sPeZdZdZeZer8ejj	d�Zdj	d�Z
edd��ZnejZdZ
e
jjZdZdZdZdZdd�ZedCdd
��Zdd�Zedd��Zedd��Zdd�Zdd�ZdDdd�Zdd�Zdd�ZdEdd�Zd d!�Z d"d#�Z!dFd%d&�Z"d'd(�Z#dGd)d*�Z$dHd+d,�Zd-d.�Z%d/d0�Z&d1d2�Z'd3d4�Z(dId6d7�Z)d8d9�Z*d:d;�Z+d<d=�Z,d>d?�Z-d@dA�Z.dS)J�
PtyProcessz�This class represents a process running in a pseudoterminal.
    
    The main constructor is the :meth:`spawn` classmethod.
    �asciiz
cCs8ytjjj|�Stk
r2tjj|jdd��SXdS)NrC�replace)r�stdout�buffer�write�AttributeError�decode)�brrr
�write_to_stdout�szPtyProcess.write_to_stdoutNcCsvt�||_||_tj|ddd�}tj|dddd�}tj||�|_d|_d|_d|_	d|_
d|_d|_d|_
d|_dS)N�rbr)�	buffering�wbF)rM�closefdg�������?)r+�pidr)�io�open�BufferedRWPair�fileobj�
terminated�closed�
exitstatus�signalstatus�status�flag_eof�delayafterclose�delayafterterminate)�selfrPr)ZreadfZwritefrrr
�__init__�szPtyProcess.__init__T��PcNCs�t|ttf�std|��|dd�}|d}t|�}|dkrNtdd|��|}||d<tj�\}	}
trxt	j
�\}}ntj�\}}|t
k�r�yttf|��Wn:tk
r�}
z|
jdtjtjfkrʂWYdd}
~
XnX|�s6yttd�WnDttjfk
�r4}
z |
jdtjtjfk�r$�WYdd}
~
XnXtj|	�tj|
tjtj�tjtj�d}tjd|
�tj|
d|�|dk	�r�tj |�|dk	�ry
|�Wnnt!k
�r}zPt"|�j#}d	j$|t%|��}t&�r�|j'd
�}tj(|
|�tj|
�tj)d�WYdd}~XnXy*|dk�r0tj*||�ntj+|||�Wnht,k
�r�}
zJdj$|
jt%|
��}t&�rv|j'd
�}tj(|
|�tj|
�tj)tj-�WYdd}
~
XnX|||�}||_.|dk	�r�||_/|dk	�r�||_0tj|
�tj1|	d�}tj|	�t2|�dk�rryL|j3d
d�\}}}t4t5|j6d�t!�}||j6d
d��}|t,k�rRt7|�|_Wnt!d|��YnX|�y|j8|�WnBtk
�r�}
z$|
jdtjtjtj9fk�r��WYdd}
~
XnX|S)a%Start the given command in a child process in a pseudo terminal.

        This does all the fork/exec type of stuff for a pty, and returns an
        instance of PtyProcess.

        If preexec_fn is supplied, it will be called with no arguments in the
        child process before exec-ing the specified command.
        It may, for instance, set signal handlers to SIG_DFL or SIG_IGN.

        Dimensions of the psuedoterminal used for the subprocess can be
        specified as a tuple (rows, cols), or the default (24, 80) will be used.
        z)Expected a list or tuple for argv, got %rNrz%The command was not found or was not zexecutable: %s.Fr	rz{}:0:{}zutf-8z
OSError:{}:{}i�:�rCrDz)Subprocess failed, got bad error data: %r):�
isinstance�list�tuple�	TypeErrorrr�os�pipe�use_native_pty_fork�pty�forkrZfork_ptyrrArr'r.r/r0ZENOTTYr6rr(�closer<ZF_SETFDZ
FD_CLOEXEC�resourceZ	getrlimitZ
RLIMIT_NOFILE�
closerange�chdir�	Exception�typer�format�str�PY3�encoderG�_exit�execv�execvper&�EX_OSERR�argv�env�
launch_dir�read�len�splitr9�builtinsrI�int�
setwinsizeZENXIO)�clsrz�cwdr{�echoZ
preexec_fnZ
dimensionsZcommandZcommand_with_pathZexec_err_pipe_readZexec_err_pipe_writerPr)r5Zmax_fd�eZenameZtosendZinstZ
exec_err_dataZerrclassZerrno_sr3�exctypeZ	exceptionrrr
�spawn�s�	

















zPtyProcess.spawncCs|t|�j}|jdk	rft|j�g}|jdk	r:|jd|j�|jdk	rT|jd|j�dj|dj|��Sdj||j	|j
�SdS)Nzenv=%rzcwd=%rz{}.spawn({})z, z{}(pid={}, fd={}))rqrrz�reprr{�appendr|rr�joinrPr))r]Zclsnamer.rrr
�__repr__Ms



zPtyProcess.__repr__cCst|t�s|jd�S|S)Nzutf-8)rcr
ru)r@rrr
�_coerce_send_string[s

zPtyProcess._coerce_send_stringcCs|S)Nr)r@rrr
�_coerce_read_stringaszPtyProcess._coerce_read_stringc	Cs$|js y|j�WnYnXdS)aLThis makes sure that no system resources are left open. Python only
        garbage collects Python objects. OS file descriptors are not Python
        objects, so they must be handled explicitly. If the child file
        descriptor was opened outside of this class (passed to the constructor)
        then this does not close it. N)rVrl)r]rrr
�__del__es
zPtyProcess.__del__cCs|jS)zCThis returns the file descriptor of the pty for the child.
        )r))r]rrr
r wszPtyProcess.filenocCsN|jsJ|j�|jj�tj|j�|j�r>|j|�s>t	d��d|_
d|_dS)a?This closes the connection with the child application. Note that
        calling close() more than once is valid. This emulates standard Python
        behavior with files. Set force to True if you want to make sure that
        the child is terminated (SIGKILL is sent if the child ignores SIGHUP
        and SIGINT). zCould not terminate the child.rTN���)rV�flushrTrl�time�sleepr[�isalive�	terminater,r))r]�forcerrr
rl|s

zPtyProcess.closecCsdS)zWThis does nothing. It is here to support the interface for a
        File-like object. Nr)r]rrr
r��szPtyProcess.flushcCstj|j�S)a^This returns True if the file descriptor is open and connected to a
        tty(-like) device, else False.

        On SVR4-style platforms implementing streams, such as SunOS and HP-UX,
        the child pty may not appear as a terminal device.  This means
        methods such as setecho(), setwinsize(), getwinsize() may raise an
        IOError. )rg�isattyr))r]rrr
r��s	zPtyProcess.isattycCs\|dk	rtj�|}xB|j�s"dS|dkr6|dk	r6dS|dk	rJ|tj�}tjd�qWdS)a�This waits until the terminal ECHO flag is set False. This returns
        True if the echo mode is off. This returns False if the ECHO flag was
        not set False before the timeout. This can be used to detect when the
        child is waiting for a password. Usually a child application will turn
        off echo mode when it is waiting for the user to enter a password. For
        example, instead of expecting the "password:" prompt you can wait for
        the child to set ECHO off::

            p = pexpect.spawn('ssh user@example.com')
            p.waitnoecho()
            p.sendline(mypassword)

        If timeout==None then this method to block until ECHO flag is False.
        NTrFg�������?)r��getechor�)r]ZtimeoutZend_timerrr
�
waitnoecho�szPtyProcess.waitnoechocCs�ytj|j�}WnXtjk
rh}z:d}|jdtjkrVt|jdd|jd|f���WYdd}~XnXt|dtj	@�|_
|j
S)aThis returns the terminal echo mode. This returns True if echo is
        on or False if echo is off. Child applications that are expecting you
        to enter a password often set ECHO False. See waitnoecho().

        Not supported on platforms where ``isatty()`` returns False.  z,getecho() may not be called on this platformrz%s: %s.rNr	)rr$r)r(r.r/r0r'�boolr1r�)r]r4r5r3rrr
r��szPtyProcess.getechocCst|j|�||_dS)aZThis sets the terminal echo mode on or off. Note that anything the
        child sent before the echo will be lost, so you should be sure that
        your input buffer is empty before you call setecho(). For example, the
        following will work as expected::

            p = pexpect.spawn('cat') # Echo is on by default.
            p.sendline('1234') # We expect see this twice from the child...
            p.expect(['1234']) # ... once from the tty echo...
            p.expect(['1234']) # ... and again from cat itself.
            p.setecho(False) # Turn off tty echo
            p.sendline('abcd') # We will set this only once (echoed by cat).
            p.sendline('wxyz') # We will set this only once (echoed by cat)
            p.expect(['abcd'])
            p.expect(['wxyz'])

        The following WILL NOT WORK because the lines sent before the setecho
        will be lost::

            p = pexpect.spawn('cat')
            p.sendline('1234')
            p.setecho(False) # Turn off tty echo
            p.sendline('abcd') # We will set this only once (echoed by cat).
            p.sendline('wxyz') # We will set this only once (echoed by cat)
            p.expect(['1234'])
            p.expect(['1234'])
            p.expect(['abcd'])
            p.expect(['wxyz'])


        Not supported on platforms where ``isatty()`` returns False.
        N)r6r)r�)r]r2rrr
�setecho�s zPtyProcess.setecho�cCsry|jj|�}WnFttfk
rV}z&|jdtjkrDd|_td���WYdd}~XnX|dkrnd|_td��|S)aRead and return at most ``size`` bytes from the pty.

        Can block if there is nothing to read. Raises :exc:`EOFError` if the
        terminal was closed.
        
        Unlike Pexpect's ``read_nonblocking`` method, this doesn't try to deal
        with the vagaries of EOF on platforms that do strange things, like IRIX
        or older Solaris systems. It handles the errno=EIO pattern used on
        Linux, and the empty-string return used on BSD platforms and (seemingly)
        on recent Solaris.
        rTz,End Of File (EOF). Exception style platform.N�z/End Of File (EOF). Empty string style platform.)	rT�read1r&r'r.r/�EIOrZ�EOFError)r]�sizer@r5rrr
r}�szPtyProcess.readcCspy|jj�}WnFttfk
rT}z&|jdtjkrBd|_td���WYdd}~XnX|dkrld|_td��|S)z�Read one line from the pseudoterminal, and return it as unicode.

        Can block if there is nothing to read. Raises :exc:`EOFError` if the
        terminal was closed.
        rTz,End Of File (EOF). Exception style platform.Nr�z/End Of File (EOF). Empty string style platform.)	rT�readliner&r'r.r/r�rZr�)r]r@r5rrr
r�szPtyProcess.readlinecCs|jj|�}|r|jj�|S)N)rTrGr�)r]rJr��nrrr
�_writeb s
zPtyProcess._writebcCs|j||d�S)zaWrite bytes to the pseudoterminal.
        
        Returns the number of bytes written.
        )r�)r�)r]r@r�rrr
rG&szPtyProcess.writec
Cs�|j�}t|�}d|ko"dknrN|td�d}t|�}|j|�|fSddddddddd	d	d
dd�}||krxdSt||�}|j|�|fS)aHelper method that wraps send() with mnemonic access for sending control
        character to the child (such as Ctrl-C or Ctrl-D).  For example, to send
        Ctrl-G (ASCII 7, bell, '')::

            child.sendcontrol('g')

        See also, sendintr() and sendeof().
        �a�z�arr������)�@�`�[�{�\�|�]�}�^�~�_�?r�)rr�)�lowerr#rr�)r]�charr�Zbyte�drrr
�sendcontrol-s"	zPtyProcess.sendcontrolcCs|jt�tfS)a1This sends an EOF to the child. This sends a character which causes
        the pending parent output buffer to be sent to the waiting child
        program without waiting for end-of-line. If it is the first character
        of the line, the read() in the user program returns 0, which signifies
        end-of-file. This means to work as expected a sendeof() has to be
        called at the beginning of a line. This method does not send a newline.
        It is the responsibility of the caller to ensure the eof is sent at the
        beginning of a line. )r�r)r]rrr
�sendeofIs
zPtyProcess.sendeofcCs|jt�tfS)znThis sends a SIGINT to the child. It does not require
        the SIGINT to be the first character on a line. )r�r)r]rrr
�sendintrUszPtyProcess.sendintrcCs|jS)z@This returns True if the EOF exception was ever raised.
        )rZ)r]rrr
r*[szPtyProcess.eofFcCs�|j�sdSy�|jtj�tj|j�|j�s2dS|jtj�tj|j�|j�sVdS|jtj�tj|j�|j�szdS|r�|jtj	�tj|j�|j�s�dSdSdSt
k
r�tj|j�|j�s�dSdSYnXdS)z�This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. TFN)r��kill�signal�SIGHUPr�r�r\�SIGCONT�SIGINT�SIGKILLr&)r]r�rrr
r�as6zPtyProcess.terminatecCs�|j�rtj|jd�\}}n|jStj|�|_tj|�rX||_tj|�|_d|_d|_	n<tj
|�r�||_d|_tj|�|_d|_	ntj|�r�t
d��|jS)	amThis waits until the child exits. This is a blocking call. This will
        not read any data from the child, so this will block forever if the
        child has unread output and has terminated. In other words, the child
        may have printed output then called exit(), but, the child is
        technically still alive until its output is read by the parent. rNTz!Called wait() on a stopped child z.process. This is not supported. Is some other z2process attempting job control with our child pid?zOCalled wait() on a stopped child process. This is not supported. Is some other z�Called wait() on a stopped child process. This is not supported. Is some other process attempting job control with our child pid?)r�rg�waitpidrPrW�WEXITSTATUS�	WIFEXITEDrYrXrU�WIFSIGNALED�WTERMSIG�
WIFSTOPPEDr,)r]rPrYrrr
�wait�s&


zPtyProcess.waitcCsP|jr
dS|jrd}ntj}ytj|j|�\}}Wn:tk
rl}z|jtjkrZt	d��n�WYdd}~XnX|dkr�ytj|j|�\}}Wn:tk
r�}z|jtjkr�t	d��n�WYdd}~XnX|dkr�d	S|dkr�d	Stj
|��r||_tj|�|_
d|_d	|_n@tj|��r8||_d|_
tj|�|_d	|_ntj|��rLt	d��dS)aZThis tests if the child process is running or not. This is
        non-blocking. If the child was terminated then this will read the
        exitstatus or signalstatus of the child. This returns True if the child
        process appears to be running or False if not. It can take literally
        SECONDS for Solaris to return the right status. Frz isalive() encountered condition z0where "terminated" is 0, but there was no child z)process. Did someone else call waitpid() zon our process?Nz-that should never happen. There was no child Tz,where child process is stopped. This is not z,supported. Is some other process attempting zjob control with our child pid?zPisalive() encountered condition where "terminated" is 0, but there was no child zyisalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() z�isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process?zMisalive() encountered condition that should never happen. There was no child zvisalive() encountered condition that should never happen. There was no child process. Did someone else call waitpid() z�isalive() encountered condition that should never happen. There was no child process. Did someone else call waitpid() on our process?zLisalive() encountered condition where child process is stopped. This is not zxisalive() encountered condition where child process is stopped. This is not supported. Is some other process attempting z�isalive() encountered condition where child process is stopped. This is not supported. Is some other process attempting job control with our child pid?)rUrZrg�WNOHANGr�rPr&r/ZECHILDr,r�rYr�rWrXr�r�r�)r]Zwaitpid_optionsrPrYr�rrr
r��sRzPtyProcess.isalivecCs|j�rtj|j|�dS)aSend the given signal to the child application.

        In keeping with UNIX tradition it has a misleading name. It does not
        necessarily kill the child unless you send the right signal. See the
        :mod:`signal` module for constants representing signal numbers.
        N)r�rgr�rP)r]Zsigrrr
r��s	zPtyProcess.killcCsBttdd�}tjddddd�}tj|j||�}tjd|�dd�S)zNReturn the window size of the pseudoterminal as a tuple (rows, cols).
        �
TIOCGWINSZiht@r8rrb)r9rr:r;r<r=r)�unpack)r]r�r@�xrrr
�
getwinsize�szPtyProcess.getwinsizecCst|j||�S)a@Set the terminal window size of the child tty.

        This will cause a SIGWINCH signal to be sent to the child. This does not
        change the physical window size. It changes the size reported to
        TTY-aware applications like vi or curses -- applications that respond to
        the SIGWINCH signal.
        )rAr))r]r>r?rrr
r�szPtyProcess.setwinsize�r_r`)NNTNr�)T)N)r�)T)T)F)/rrrr-r
�string_typertrg�linesepruZcrlf�staticmethodrKrrErG�encodingrzr{r|r^�classmethodr�r�r�r�r�r rlr�r�r�r�r�r}r�r�r�r�r�r*r�r�r�r�r�r�rrrr
rB|sV


$



(MrBcsVeZdZdZereZneZd
�fdd�	Zd�fdd�	Z	�fd	d
�Z
�fdd�Z�ZS)�PtyProcessUnicodez�Unicode wrapper around a process running in a pseudoterminal.

    This class exposes a similar interface to :class:`PtyProcess`, but its read
    methods return unicode, and its :meth:`write` accepts unicode.
    �utf-8�strictcs4tt|�j||�||_||_tj|�|d�|_dS)N)�errors)�superr�r^r��codec_errors�codecs�getincrementaldecoder�decoder)r]rPr)r�r�)�	__class__rr
r^szPtyProcessUnicode.__init__�cs tt|�j|�}|jj|dd�S)aRead at most ``size`` bytes from the pty, return them as unicode.

        Can block if there is nothing to read. Raises :exc:`EOFError` if the
        terminal was closed.

        The size argument still refers to bytes, not unicode code points.
        F)�final)r�r�r}r�rI)r]r�rJ)r�rr
r}#szPtyProcessUnicode.readcstt|�j�}|jj|dd�S)z�Read one line from the pseudoterminal, and return it as unicode.

        Can block if there is nothing to read. Raises :exc:`EOFError` if the
        terminal was closed.
        F)r�)r�r�r�r�rI)r]rJ)r�rr
r�.szPtyProcessUnicode.readlinecs|j|j�}tt|�j|�S)zlWrite the unicode string ``s`` to the pseudoterminal.

        Returns the number of bytes written.
        )rur�r�r�rG)r]r@rJ)r�rr
rG7szPtyProcessUnicode.write)r�r�)r�)
rrrr-rtrsr�Zunicoder^r}r�rG�
__classcell__rr)r�r
r�s	r�)NN)+r�r/r<rQrgrjrmr�r:rrr�r�r%Z__builtin__rr�utilr�platformr�Z	_platform�
startswithZ_is_solarisri�r�version_infortrr&rrrrr+rpr,r6rA�objectrBr�rrrr
�<module>sT



!


Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 292 B 0644
__init__.cpython-36.pyc File 292 B 0644
_fork_pty.cpython-36.opt-1.pyc File 1.85 KB 0644
_fork_pty.cpython-36.pyc File 1.85 KB 0644
ptyprocess.cpython-36.opt-1.pyc File 23.33 KB 0644
ptyprocess.cpython-36.pyc File 23.33 KB 0644
util.cpython-36.opt-1.pyc File 1.67 KB 0644
util.cpython-36.pyc File 1.67 KB 0644