__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

���gkD����SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSK
r
SSKrSSKrSSKrS\lSrSr/SQr\R2SS	:�r"S
S\5r"SS
\5r"SS\5rSSjrSSjr Sr!"SS\"5r#"SS\#5r$"SS\"5r%"SS\"5r&Sr'Sr(g!\a& \R&"5Sr\"\"\5S-5ef=f)a�Pexpect is a Python module for spawning child applications and controlling
them automatically. Pexpect can be used for automating interactive applications
such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup
scripts for duplicating software package installations on different servers. It
can be used for automated software testing. Pexpect is in the spirit of Don
Libes' Expect, but Pexpect is pure Python. Other Expect-like modules for Python
require TCL and Expect or require C extensions to be compiled. Pexpect does not
use C, Expect, or TCL extensions. It should work on any platform that supports
the standard Python pty module. The Pexpect interface focuses on ease of use so
that simple tasks are easy.

There are two main interfaces to the Pexpect system; these are the function,
run() and the class, spawn. The spawn class is more powerful. The run()
function is simpler than spawn, and is good for quickly calling program. When
you call the run() function it executes a given program and then returns the
output. This is a handy replacement for os.system().

For example::

    pexpect.run('ls -la')

The spawn class is the more powerful interface to the Pexpect system. You can
use this to spawn a child program then interact with it by sending input and
expecting responses (waiting for patterns in the child's output).

For example::

    child = pexpect.spawn('scp foo [email protected]:.')
    child.expect('Password:')
    child.sendline(mypassword)

This works even for commands that ask for passwords or other input outside of
the normal stdio streams. For example, ssh reads input directly from the TTY
device which bypasses stdin.

Credits: Noah Spurrier, Richard Holden, Marco Molteni, Kimberley Burchett,
Robert Stone, Hartmut Goebel, Chad Schroeder, Erick Tryzelaar, Dave Kirby, Ids
vander Molen, George Todd, Noel Taylor, Nicolas D. Cesar, Alexander Gattin,
Jacques-Etienne Baudoux, Geoffrey Marshall, Francisco Lourenco, Glen Mabey,
Karthik Gurusamy, Fernando Perez, Corey Minyard, Jon Cohen, Guillaume
Chazarain, Andrew Ryan, Nick Craig-Wood, Andrew Stone, Jorgen Grahn, John
Spiegel, Jan Grant, and Shane Kerr. Let me know if I forgot anyone.

Pexpect is free, open source, and all that good stuff.
http://pexpect.sourceforge.net/

PEXPECT LICENSE

    This license is approved by the OSI and FSF as GPL-compatible.
        http://opensource.org/licenses/isc-license.txt

    Copyright (c) 2012, Noah Spurrier <[email protected]>
    PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY
    PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE
    COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES.
    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

�NT�z�

A critical module was not found. Probably this operating system does not
support it. Pexpect is intended for UNIX-like operating systems.z3.1�)�ExceptionPexpect�EOF�TIMEOUT�spawn�spawnu�run�runu�which�split_command_line�__version__�__revision__�c�8^�\rSrSrSrU4SjrSrSrSrU=r	$)r�cz9Base class for all exceptions raised by this module.
    c�8>�[[U]U5 Xlg�N)�superr�__init__�value)�selfr�	__class__s  ��)/usr/share/hplip/base/pexpect/__init__.pyr�ExceptionPexpect.__init__gs���
���.�u�5��
�c�,�[UR5$r)�strr�rs r�__str__�ExceptionPexpect.__str__ks���4�:�:��rc���[R"[R"5S5nUVs/sHnSUS;dMUPM nn[R"U5nSRU5$s snf)z�This returns an abbreviated stack trace with lines that only concern
the caller. In other words, the stack trace inside the Pexpect module
is not included. �zpexpect/__init__rr)�	traceback�
extract_tb�sys�exc_info�format_list�join)r�tblist�items   r�	get_trace�ExceptionPexpect.get_tracensc��
�%�%�c�l�l�n�Q�&7�8��#)�O�6�4�-?�t�A�w�-N�$�6��O��&�&�v�.���w�w�v����Ps�
A1�A1)r)
�__name__�
__module__�__qualname__�__firstlineno__�__doc__rr r,�__static_attributes__�
__classcell__�rs@rrrcs�������rrc��\rSrSrSrSrg)r�yzNRaised when EOF is read from a child.
This usually means the child has exited.�N�r.r/r0r1r2r3r8rrrrys��0rrc��\rSrSrSrSrg)r�~z-Raised when a read time exceeds the timeout. r8Nr9r8rrrr~s��7rrc�&�[XUX4XVU[S9	$)a�

This function runs the given command; waits for it to finish; then
returns all output as a string. STDERR is included in output. If the full
path to the command is not given then the path is searched.

Note that lines are terminated by CR/LF (\r\n) combination even on
UNIX-like systems because this is the standard for pseudottys. If you set
'withexitstatus' to true, then run will return a tuple of (command_output,
exitstatus). If 'withexitstatus' is false then this returns just
command_output.

The run() function can often be used instead of creating a spawn instance.
For example, the following code uses spawn::

    from pexpect import *
    child = spawn('scp foo [email protected]:.')
    child.expect('(?i)password')
    child.sendline(mypassword)

The previous code can be replace with the following::

    from pexpect import *
    run('scp foo [email protected]:.', events={'(?i)password': mypassword})

**Examples**

Start the apache daemon on the local machine::

    from pexpect import *
    run("/usr/local/apache/bin/apachectl start")

Check in a file using SVN::

    from pexpect import *
    run("svn ci -m 'automatic commit' my_file.py")

Run a command and capture exit status::

    from pexpect import *
    (command_output, exitstatus) = run('ls -l /bin', withexitstatus=1)

The following will run SSH and execute 'ls -l' on the remote machine. The
password 'secret' will be sent if the '(?i)password' pattern is ever seen::

    run("ssh [email protected] 'ls -l'",
        events={'(?i)password':'secret\n'})

This will start mencoder to rip a video from DVD. This will also display
progress ticks every 5 seconds as it runs. For example::

    from pexpect import *
    def print_ticks(d):
        print d['event_count'],
    run("mencoder dvd://1 -o video.avi -oac copy -ovc copy",
        events={TIMEOUT:print_ticks}, timeout=5)

The 'events' argument should be a dictionary of patterns and responses.
Whenever one of the patterns is seen in the command out run() will send the
associated response string. Note that you should put newlines in your
string if Enter is necessary. The responses may also contain callback
functions. Any callback is function that takes a dictionary as an argument.
The dictionary contains all the locals from the run() function, so you can
access the child spawn object or any other variable defined in run()
(event_count, child, and extra_args are the most useful). A callback may
return True to stop the current run process otherwise run() continues until
the next event. A callback may also return a string which will be sent to
the child. 'extra_args' is not used by directly run(). It provides a way to
pass data to a callback function through run() through the locals
dictionary passed to a callback.
��timeout�withexitstatus�events�
extra_args�logfile�cwd�env�_spawn)�_runr)�commandr>r?r@rArBrCrDs        rr
r
�s ��R����g���'�'rc�.�[U4XX4XVU[S.UD6$)z�This offers the same interface as :func:`run`, but using unicode.

Like :class:`spawnu`, you can pass ``encoding`` and ``errors`` parameters,
which will be used for both input and output.
r=)rFr	)	rGr>r?r@rArBrCrD�kwargss	         rrr�s,����2���g���2�*0�2�2rc		��US:XaU"U4SXVUS.U	D6n
OU"U4USUXgS.U	D6n
Ub3[UR55n[UR55nOSnSn/n
SnU
RU5n[	U
R
U
R5(a)U
RU
RU
R
-5 OU
RU
R5 [	X�U
R5(aU
RX�5 O�[	X�[R5(afX�"[55n[RR5 [	UU
R5(aU
RU5 OU(aOO[!S5eUS-nGMFU
R'5R)U
5nU(aU
R+5 UU
R,4$U$!["a U
RU
R5 Mn[$a U
RU
R5 M�f=f)N�����)�maxreadrBrCrD)r>rMrBrCrDrz*The callback must be a string or function.r)�list�keys�values�expect�
isinstance�after�allowed_string_types�append�before�send�types�FunctionType�localsr&�stdout�flush�	TypeErrorrr�string_typer)�close�
exitstatus)rGr>r?r@rArBrCrDrErI�child�patterns�	responses�child_result_list�event_count�index�callback_result�child_results                  rrFrF�s���"�}��w�"��g�C�"� �"���w�,���w��,�$*�,��
������
�&�������)�	����	����K�
�	��L�L��*�E��%�+�+�u�'A�'A�B�B�!�(�(�������)C�D�"�(�(����6��)�*�E�,F�,F�G�G��
�
�9�+�,��I�,�e�.@�.@�A�A�"+�"2�6�8�"<���
�
� � �"��o�u�/I�/I�J�J��J�J��/�$��%� � L�M�M�%��/�K�)�6�$�$�&�+�+�,=�>�L��
���
��e�.�.�/�/�����	��$�$�U�\�\�2���	��$�$�U�\�\�2��	�s�#D0G.�G.�.%H>�$H>�=H>c��\rSrSrSr\r\(a0\\4r	\
S5r\RRS5r
\
S5rO-\4r	\
"\5r\Rr
\R&R(rSr/SSSSSSS	4S
jr\
S5r\
S5r\
S
5rSrSr/4SjrSrSrSrS>Sjr Sr!Sr"S?Sjr#Sr$Sr%Sr&S@Sjr'S?Sjr(S?Sjr)Sr*S?Sjr+S rS!r,S"r-S#r.SAS$jr/S%r0S&r1S'r2S(r3SBS)jr4S*r5S+r6S,r7S-r8S.r9SCS/jr:SCS0jr;SCS1jr<SCS2jr=S3r>S4r?\"S55SS4S6jr@S7rAS8rBSDS9jrCSES:jrDS;rES<rFS=rGg)FrizfThis is the main class interface for Pexpect. Use this class to start
and control child applications. c��[U/5$r)�bytes)�cs r�_chr�
spawn._chrs���!��:�r�asciic���[RRRU5$![a2 [RRURSS55s$f=f)Nro�replace)r&r[�buffer�write�AttributeError�decode)�bs r�write_to_stdout�spawn.write_to_stdout!sT��
F��z�z�(�(�.�.�q�1�1��!�
F��z�z�'�'�����)�(D�E�E�
F�s�(+�9A'�&A'N�rLTc
�x�[RUl[RUl[RUl[R
Ul[RUl[RUlSUlSUl	SUl
SUlSUlSUl
SUlSUlSUlSUlSUlSUlSUlX0l[,UlX`lSUlSUlX@lUR95UlXPlSUlSUl SUl!SUl"S[GU5-S-Ul$SUl%Xpl&X�l'X�l([RRRU5RWS	5S
:�Ul,[RRRU5RWS5S
:�d1[RRRU5RWS5S
:�aSUl-OSUl-UcSUl.SUl/S
Ul$gURaX5 g)a�This is the constructor. The command parameter may be a string that
includes a command and any arguments to the command. For example::

    child = pexpect.spawn('/usr/bin/ftp')
    child = pexpect.spawn('/usr/bin/ssh [email protected]')
    child = pexpect.spawn('ls -latr /tmp')

You may also construct it with a list of arguments like so::

    child = pexpect.spawn('/usr/bin/ftp', [])
    child = pexpect.spawn('/usr/bin/ssh', ['[email protected]'])
    child = pexpect.spawn('ls', ['-latr', '/tmp'])

After this the child application will be created and will be ready to
talk to. For normal use, see expect() and send() and sendline().

Remember that Pexpect does NOT interpret shell meta characters such as
redirect, pipe, or wild cards (``>``, ``|``, or ``*``). This is a
common mistake.  If you want to run a command and pipe it through
another command then you must also start a shell. For example::

    child = pexpect.spawn('/bin/bash -c "ls -l | grep LOG > logs.txt"')
    child.expect(pexpect.EOF)

The second form of spawn (where you pass a list of arguments) is useful
in situations where you wish to spawn a command and pass it its own
argument list. This can make syntax more clear. For example, the
following is equivalent to the previous example::

    shell_cmd = 'ls -l | grep LOG > logs.txt'
    child = pexpect.spawn('/bin/bash', ['-c', shell_cmd])
    child.expect(pexpect.EOF)

The maxread attribute sets the read buffer size. This is maximum number
of bytes that Pexpect will try to read from a TTY at one time. Setting
the maxread size to 1 will turn off buffering. Setting the maxread
value higher may help performance in cases where large amounts of
output are read back from the child. This feature is useful in
conjunction with searchwindowsize.

The searchwindowsize attribute sets the how far back in the incoming
seach buffer Pexpect will search for pattern matches. Every time
Pexpect reads some data from the child it will append the data to the
incoming buffer. The default is to search from the beginning of the
incoming buffer each time new data is read from the child. But this is
very inefficient if you are running a command that generates a large
amount of data where you want to match. The searchwindowsize does not
affect the size of the incoming data buffer. You will still have
access to the full buffer after expect() returns.

The logfile member turns on or off logging. All input and output will
be copied to the given file object. Set logfile to None to stop
logging. This is the default. Set logfile to sys.stdout to echo
everything to standard output. The logfile is flushed after each write.

Example log input and output to a file::

    child = pexpect.spawn('some_command')
    fout = file('mylog.txt','w')
    child.logfile = fout

Example log to stdout::

    child = pexpect.spawn('some_command')
    child.logfile = sys.stdout

The logfile_read and logfile_send members can be used to separately log
the input from the child and output sent to the child. Sometimes you
don't want to see everything you write to the child. You only want to
log what the child sends back. For example::

    child = pexpect.spawn('some_command')
    child.logfile_read = sys.stdout

To separately log output sent to the child use logfile_send::

    self.logfile_send = fout

If ``ignore_sighup`` is True, the child process will ignore SIGHUP
signals. For now, the default is True, to preserve the behaviour of
earlier versions of Pexpect, but you should pass this explicitly if you
want to rely on it.

The delaybeforesend helps overcome a weird behavior that many users
were experiencing. The typical problem was that a user would expect() a
"Password:" prompt and then immediately call sendline() to send the
password. The user would then see that their password was echoed back
to them. Passwords don't normally echo. The problem is caused by the
fact that most applications print out the "Password" prompt and then
turn off stdin echo, but if you send your password before the
application turned off echo, then you get your password echoed.
Normally this wouldn't be a problem when interacting with a human at a
real keyboard. If you introduce a slight delay just before writing then
this seems to clear up the problem. This was such a common problem for
many users that I decided that the default pexpect behavior should be
to sleep just before writing to the child application. 1/20th of a
second (50 ms) seems to be enough to clear up the problem. You can set
delaybeforesend to 0 to return to the old behavior. Most Linux machines
don't like this to be below 0.03. I don't know why.

Note that spawn is clever about finding commands on your path.
It uses the same logic that "which" uses to find executables.

If you wish to get the exit status of the child you must call the
close() method. The exit or signal status of the child will be stored
in self.exitstatus or self.signalstatus. If the child exited normally
then exitstatus will store the exit return code and signalstatus will
be None. If the child was terminated abnormally with a signal then
signalstatus will store the signal value and exitstatus will be None.
If you need more detail you can also read the self.status member which
stores the status returned by os.waitpid. You can interpret this using
os.WIFEXITED/os.WEXITSTATUS or os.WIFSIGNALED/os.TERMSIG. NFTrKg�������?皙�����?�<�>�irixr�solaris�sunos5z<pexpect factory incomplete>)1�pty�STDIN_FILENO�
STDOUT_FILENO�
STDERR_FILENOr&�stdinr[�stderr�searcher�
ignorecaserVrS�match�match_index�
terminatedr`�signalstatus�status�flag_eof�pid�child_fdr>r�	delimiterrB�logfile_read�logfile_sendrMr^rr�searchwindowsize�delaybeforesend�delayafterclose�delayafterterminate�	softspace�repr�name�closedrCrD�
ignore_sighup�platform�lower�find�_spawn__irix_hack�use_native_pty_forkrG�argsrE)
rrGr�r>rMr�rBrCrDr�s
          rr�spawn.__init__0s���j �,�,��� �.�.��� �.�.����Y�Y��
��j�j����j�j�����
���������
���
���������� ��������
������
�������� ��� ������&�&�(��� 0�� $��� #���$'�� �����$�t�*�$�s�*��	��������*���L�L�.�.�0�5�5�f�=��B���
�\�\�
�
�
!�
&�
&�y�
1�Q�
6����"�"�$�)�)�(�3�q�8�',�D�$�'+�D�$��?��D�L��D�I�6�D�I��K�K��&rc�R�[U[5(dURS5$U$)Nro�rRrk�encode��ss r�_coerce_expect_string�spawn._coerce_expect_string��#���!�U�#�#��8�8�G�$�$��rc�R�[U[5(dURS5$U$)N�utf-8r�r�s r�_coerce_send_string�spawn._coerce_send_string�r�rc��U$rr8r�s r�_coerce_read_string�spawn._coerce_read_string�����rc�X�UR(dUR5 gg! g=f)a,This 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)r�r_rs r�__del__�
spawn.__del__�s(���{�{�
��
�
����
��s�%�)c��/nUR[U55 URS[-5 URS[UR5-5 URSUR
<35 URSUR<35 URSURSS-5 URSURSS-5 URS	UR<35 URS
UR<35 URS[UR5-5 URS[UR5-5 URS
[UR5-5 URS[UR5-5 URS[UR5-5 URS[UR 5-5 URS[UR"5-5 URS[UR$5-5 URS[UR&5-5 URS[UR(5-5 URS[UR*5-5 URS[UR,5-5 URS[UR.5-5 URS[UR05-5 URS[UR25-5 URS[UR45-5 URS[UR65-5 SR9U5$)zNThis returns a human-readable string that represents the state of
the object. z	version: z	command: zargs: z
searcher: zbuffer (last 100 chars): %ri����Nzbefore (last 100 chars): %rzafter: zmatch: z
match_index: zexitstatus: z
flag_eof: zpid: z
child_fd: zclosed: z	timeout: zdelimiter: z	logfile: zlogfile_read: zlogfile_send: z	maxread: zignorecase: zsearchwindowsize: zdelaybeforesend: zdelayafterclose: zdelayafterterminate: �
)rUr�rrrGr�r�rrrVrSr�r�r`r�r�r�r�r>r�rBr�r�rMr�r�r�r�r�r)�rr�s  rr �
spawn.__str__	s���
��	����d���	����{�*�+�	����s�4�<�<�0�0�1�	���t�y�y�*�+�	���4�=�=�2�3�	���.�$�+�+�t�u�1E�E�G�	���.�$�+�+�t�u�1E�E�G�	����
�
�,�-�	����
�
�,�-�	����3�t�'7�'7�#8�8�9�	����#�d�o�o�"6�6�7�	�����D�M�M� 2�2�3�	����3�t�x�x�=�(�)�	�����D�M�M� 2�2�3�	����c�$�+�+�.�.�/�	����s�4�<�<�0�0�1�	�����T�^�^�!4�4�5�	����s�4�<�<�0�0�1�	���!�C��(9�(9�$:�:�;�	���!�C��(9�(9�$:�:�;�	����s�4�<�<�0�0�1�	����#�d�o�o�"6�6�7�	���%��D�,A�,A�(B�B�C�	���$�s�4�+?�+?�'@�@�A�	���$�s�4�+?�+?�'@�@�A�	���(�3�t�/G�/G�+H�H�I��y�y��|�rc���[U[S55(a[S5e[U[/55(d[S5eU/:Xa%[	U5UlUR
SUlO,USSUlUR
RSU5 Xl[UR5nUc[SSUR--5eX0lURUR
S'SSRUR
5-S	-Ul
URbS
5eURcS5eUR(a$[R"5uUlUlOUR)5uUlUlURS:XGag["R*R-5UlUR/SS5 [0R2"[0R45Sn[7SU5Hn[8R:"U5 M UR<(a3[>R>"[>R@[>RB5 URDb [8RF"URD5 URHc,[8RJ"URUR
5 O6[8RL"URUR
URH5 SUl'SUl(g![ a0 ["R$"5Sn[S
['U5-5ef=f! GN�=f![ a GM`f=f)z�This starts the given command in a child process. This does all the
fork/exec type of stuff for a pty. This is called by __init__. If args
is empty then command will be parsed (split on spaces) and args will be
set to parsed arguments. rz�Command is an int type. If this is a file descriptor then maybe you want to use fdpexpect.fdspawn which takes an existing file descriptor instead of a command string.z#The argument, args, must be a list.Nz%The command was not found or was not zexecutable: %s.r|� r}zThe pid member must be None.z$The command member must not be None.rzpty.fork() failed: ��PrF))rR�typerr]r
r�rG�insertrr)r�r�r�r��forkr��OSErrorr&r'r�_spawn__fork_ptyr[�fileno�
setwinsize�resource�	getrlimit�
RLIMIT_NOFILE�range�osr_r��signal�SIGHUP�SIG_IGNrC�chdirrD�execv�execvper�r�)rrGr��command_with_path�err�max_fd�is       rrE�spawn._spawn*s��� �g�t�A�w�'�'�"�$C�D�
D�
�$��R��)�)��A�B�B��2�:�*�7�3�D�I��9�9�Q�<�D�L��Q��D�I��I�I���Q��(�"�L�!�$�,�,�/���$�"�#J�%����4�$5�6�
6�(���|�|��	�	�!���#�(�(�4�9�9�-�-��3��	��x�x��?�!?�?���|�|�'�O�)O�O�'��#�#�
I�*-�(�(�*�'���$�-�'+�o�o�&7�#�D�H�d�m��8�8�q�=�

� #�
�
� 1� 1� 3��
�����B�'��'�'��(>�(>�?��B�F��1�f�%����H�H�Q�K�&��!�!��
�
�f�m�m�V�^�^�<��x�x�#�������"��x�x��������t�y�y�1��
�
�4�<�<����D�H�H�=� �������Q�
I��l�l�n�Q�'��&�'<�s�3�x�'G�H�H�
I��
�
������s*�"L�&5M�M �:M�M� 
M/�.M/c��[R"5upUS:dUS:a[S5e[R"5nUS:a[S5eUS:Xa�[R"U5 URU5 [R"US5 [R"US5 [R"US5 US:�a[R"U5 X14$[R"U5 X14$)a�This implements a substitute for the forkpty system call. This
should be more portable than the pty.fork() function. Specifically,
this should work on Solaris.

Modified 10.06.05 by Geoff Marshall: Implemented __fork_pty() method to
resolve the issue with Python's pty.fork() not supporting Solaris,
particularly ssh. Based on patch to posixmodule.c authored by Noah
Spurrier::

    http://mail.python.org/pipermail/python-dev/2003-May/035281.html

rz!Could not open with os.openpty().zFailed os.fork().rr#)r��openptyrr�r_� _spawn__pty_make_controlling_tty�dup2)r�	parent_fdr�r�s    r�
__fork_pty�spawn.__fork_pty�s���!�j�j�l��	��q�=�H�q�L�"�#F�G�G��g�g�i����7�"�#6�7�7�
�A�X��H�H�Y���+�+�H�5��G�G�H�a� ��G�G�H�a� ��G�G�H�a� ��!�|�����"�
�~��
�H�H�X���~�rc��[R"U5n[R"S[R[R-5nUS:�a[R
"U5 [R"5 [R"S[R[R-5nUS:�a![R
"U5 [S5e[R"U[R5nUS:a[SU-5e[R
"U5 [R"S[R5nUS:a[S5e[R
"U5 g! GN=f! N�=f)z�This makes the pseudo-terminal the controlling tty. This should be
more portable than the pty.fork() function. Specifically, this should
work on Solaris. z/dev/ttyrzQFailed to disconnect from controlling tty. It is still possible to open /dev/tty.zCould not open child pty, z(Could not open controlling tty, /dev/ttyN)	r��ttyname�open�O_RDWR�O_NOCTTYr_�setsidr�O_WRONLY)r�tty_fd�
child_name�fds    r�__pty_make_controlling_tty� spawn.__pty_make_controlling_tty�s��
�Z�Z��'�
�	�����R�Y�Y����%<�=�B��Q�w������	�	�	��		�����R�Y�Y����%<�=�B��Q�w������&�(N�O�O���W�W�Z����
+��
��6�"�#?�*�#L�M�M��H�H�R�L��W�W�Z����
-��
��6�"�#M�N�N��H�H�R�L��?	���	��s�AE:�AF�:E?�Fc��UR$)zCThis returns the file descriptor of the pty for the child.
        )r�rs rr��spawn.fileno�s���}�}�rc�P�UR(d�UR5 [R"UR5 [
R"UR5 UR5(a!URU5(d[S5eSUlSUlgg)aThis 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.rKTN)r�r\r�r_r��time�sleepr��isalive�	terminater�r�forces  rr_�spawn.close�so���{�{��J�J�L��H�H�T�]�]�#��J�J�t�+�+�,��|�|�~�~��~�~�e�,�,�*�+K�L�L��D�M��D�K�rc��g)zOThis does nothing. It is here to support the interface for a
File-like object. Nr8rs rr\�spawn.flush�s��	
rc�B�[R"UR5$)zcThis returns True if the file descriptor is open and connected to a
tty(-like) device, else False. )r��isattyr�rs rr��spawn.isatty�s���y�y����'�'rc��US:XaURnUb[R"5U-nUR5(dgUS:aUbgUbW[R"5-
n[R"S5 MS)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 [email protected]')
    p.waitnoecho()
    p.sendline(mypassword)

If timeout==-1 then this method will use the value in self.timeout.
If timeout==None then this method to block until ECHO flag is False.
rKTrFr{)r>r��getechor�)rr>�end_times   r�
waitnoecho�spawn.waitnoecho�sp��"�b�=��l�l�G����y�y�{�W�,�H���<�<�>�>����{�w�2���"�"�T�Y�Y�[�0���J�J�s�O�rc�|�[R"UR5nUS[R-(agg)z�This 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(). rTF)�termios�	tcgetattrr��ECHO)r�attrs  rr��
spawn.getechos.��
� � ����/����7�W�\�\�!��rc�2�UR [R"UR5nU(aUS[R-US'OUS[R)-US'[R"UR[R
U5 g)aSThis 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'])
rN)r�r�r�r�	tcsetattr�TCSANOW)r�staters   r�setecho�
spawn.setecho%sl��<	
�
�
�� � ����/����1�g����,�D��G��1�g����
�-�D��G�	���$�-�-����$�?rc��URb5URRU5 URR5 US:XaUROURnUb"URU5 UR5 gg)NrW)rBrsr\r�r�)rr��	direction�
second_logs    r�_log�
spawn._logNsm���<�<�#��L�L���q�!��L�L��� �+4�f�+<�T�&�&�4�CT�CT�
��!����Q������"rc��UR(a[S5eUS:XaURnUR5(d<UR	UR
///S5up4nU(dSUl[S5eOaUR(aPUR	UR
///S5up4nU(d'UR5(dSUl[S5eUR	UR
///U5up4nU(d2UR5(dSUl[S5e[S	5eUR
U;a_[R"UR
U5nUS:XaSUl[S5eURU5nURUS
5 U$[S5e![a SUl[S
5ef=f)a�This reads at most size characters from the child application. It
includes a timeout. If the read does not complete within the timeout
period then a TIMEOUT exception is raised. If the end of file is read
then an EOF exception will be raised. If a log file was set using
setlog() then all data will also be written to the log file.

If timeout is None then the read may block indefinitely.
If timeout is -1 then the self.timeout value is used. If timeout is 0
then the child is polled and if there is no data immediately ready
then this will raise a TIMEOUT exception.

The timeout refers only to the amount of time to read at least one
character. This is not effected by the 'size' parameter, so if you call
read_nonblocking(size=100, timeout=30) and only one character is
available right away then one character will be returned immediately.
It will not wait for 30 seconds for another 99 characters to come in.

This is a wrapper around os.read(). It uses select.select() to
implement the timeout. zI/O operation on closed file.rKrTz&End Of File (EOF). Braindead platform.r#z!End Of File (EOF). Slow platform.z&End of File (EOF). Very slow platform.zTimeout exceeded.z,End Of File (EOF). Exception style platform.rz/End Of File (EOF). Empty string style platform.�readzReached an unexpected state.)r��
ValueErrorr>r��_spawn__selectr�r�rr�rr�rr�r�rr)r�sizer>�r�w�er�s       r�read_nonblocking�spawn.read_nonblockingWs���*�;�;��<�=�=��b�=��l�l�G��|�|�~�~��m�m�T�]�]�O�R��Q�?�G�A�!�� $��
��B�C�C���
�
��m�m�T�]�]�O�R��Q�?�G�A�!��T�\�\�^�^� $��
��=�>�>��-�-������R��A���a���<�<�>�>�!%��
��B�C�C��1�2�2��=�=�A��
J��G�G�D�M�M�4�0��
�C�x� $��
��K�L�L��(�(��+�A��I�I�a�� ��H��=�>�>���
J� $��
��H�I�I�
J�s�
!F6�6Gc�j�US:XaUR5$US:a'URUR5 UR$[R
"UR
SU-5[R5nURX R/5nUS:XaUR$UR$)a$This reads at most "size" bytes from the file (less if the read hits
EOF before obtaining size bytes). If the size argument is negative or
omitted, read all data until EOF is reached. The bytes are returned as
a string object. An empty string is returned when EOF is encountered
immediately. rz.{%d})	r^rQr�rV�re�compiler��DOTALLrS)rr�crerfs    rr�
spawn.read�s����1�9��#�#�%�%��!�8��K�K����'��;�;���j�j��3�3�G�d�N�C�R�Y�Y�O�����S�.�.�1�2���A�:��:�:���{�{�rc��US:XaUR5$URSUR/5nUS:XaURS-$UR$)a,This reads and returns one entire line. The newline at the end of
line is returned as part of the string, unless the file ends without a
newline. An empty string is returned if EOF is encountered immediately.
This looks for a newline as a CR/LF pair (\r\n) even on UNIX because
this is what the pseudotty device returns. So contrary to what you may
expect you will receive newlines as \r\n.

If the size argument is 0 then an empty string is returned. In all
other cases the size argument is ignored, which is not standard
behavior for a file-like object. rs
)r^rQr�rV)rrrfs   r�readline�spawn.readline�sQ���1�9��#�#�%�%����W�d�n�n�5�6���A�:��;�;��(�(��;�;�rc�J�[URUR55$)z>This is to support iterators over a file-like object.
        )�iterrr^rs r�__iter__�spawn.__iter__�s���D�M�M�4�#3�#3�#5�6�6rc�b�/nUR5nU(dU$URU5 M-)adThis reads until EOF using readline() and returns a list containing
the lines thus read. The optional 'sizehint' argument is ignored.
Remember, because this reads until EOF that means the child
process should have closed its stdout. If you run this method on
a child that is still running with its stdout open then this
method will block until it timesout.)rrU)r�sizehint�lines�lines    r�	readlines�spawn.readlines�s5������=�=�?�D�����
�L�L���	rc�&�URU5 g)zHThis is similar to send() except that there is no return value.
        N)rWr�s  rrs�spawn.write�s��	
�	�	�!�rc�8�UHnURU5 M g)z�This calls write() for each element in the sequence. The sequence
can be any iterable object producing strings, typically a list of
strings. This does not add line separators. There is no return value.
N)rs)r�sequencer�s   r�
writelines�spawn.writelines�s���A��J�J�q�M�rc��[R"UR5 URU5nUR	US5 URU5$)z�Sends string ``s`` to the child process, returning the number of
bytes written. If a logfile is specified, a copy is written to that
log. rW)r�r�r�r�r�_sendr�s  rrW�
spawn.send�sB��
	
�
�
�4�'�'�(��$�$�Q�'���	�	�!�V���z�z�!�}�rc�D�[R"URU5$r)r�rsr�r�s  rr2�spawn._sends���x�x��
�
�q�)�)rc�b�URU5nX RUR5-nU$)z~Wraps send(), sending string ``s`` to child process, with os.linesep
automatically appended. Returns number of bytes written. )rW�linesep)rr��ns   r�sendline�spawn.sendline	s+��
�I�I�a�L��
�	�	�$�,�,�'�'���rc
� �UR5n[U5nUS:�a7US::a1U[S5-
S-nURURU55$SSSSSSSSS	S	S
SS.nX;agURURX155$)
z�Helper 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���ry��)�@�`�[�{�\�|�]�}�^�~�_�?)r��ordrWrm)r�charr>�ds    r�sendcontrol�spawn.sendcontrols����z�z�|����I����7�q�C�x��C��H��q� �A��9�9�T�Y�Y�q�\�*�*��!��"��2��"��"���

���=���y�y����1�7�+�,�,rc���[[S5(a>[[R"UR5S[R
5nOSnUR
URU55 g)a�This 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. �VEOF��N)�hasattrr�rPr�r�rVrWrm�rrQs  r�sendeof�
spawn.sendeof,sS��6�7�F�#�#��w�(�(����7��:�7�<�<�H�I�D��D��	�	�$�)�)�D�/�"rc���[[S5(a>[[R"UR5S[R
5nOSnUR
URU55 g)zfThis sends a SIGINT to the child. It does not require
the SIGINT to be the first character on a line. �VINTRrWrN)rYr�rPr�r�r^rWrmrZs  r�sendintr�spawn.sendintrNsS��
�7�G�$�$��w�(�(����7��:�7�=�=�I�J�D��D��	�	�$�)�)�D�/�"rc��UR$)z@This returns True if the EOF exception was ever raised.
        )r�rs r�eof�	spawn.eofZs��
�}�}�rc�x�UR5(dgUR[R5 [R
"UR5 UR5(dgUR[R5 [R
"UR5 UR5(dgUR[R5 [R
"UR5 UR5(dgU(aVUR[R5 [R
"UR5 UR5(dggg![a: [R
"UR5 UR5(dggf=f)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. TF)r��killr�r�r�r�r��SIGCONT�SIGINT�SIGKILLr�r�s  rr��spawn.terminateas���|�|�~�~��	��I�I�f�m�m�$��J�J�t�/�/�0��<�<�>�>���I�I�f�n�n�%��J�J�t�/�/�0��<�<�>�>���I�I�f�m�m�$��J�J�t�/�/�0��<�<�>�>����	�	�&�.�.�)��
�
�4�3�3�4��|�|�~�~�� ����		�

�J�J�t�/�/�0��<�<�>�>���		�s'�AE5�-AE5�AE5�AE5�5?F9�8F9c�|�UR5(a$[R"URS5upO[	S5e[R
"U5Ul[R"U5(a;X l[R
"U5UlSUl	SUl
UR$[R"U5(a;X lSUl[R"U5Ul	SUl
UR$[R"U5(a[	S5eUR$)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. rz#Cannot wait for dead child process.NTz�Called wait() on a stopped child process. This is not supported. Is some other process attempting job control with our child pid?)r�r��waitpidr�r�WEXITSTATUSr`�	WIFEXITEDr�r�r��WIFSIGNALED�WTERMSIG�
WIFSTOPPED)rr�r�s   r�wait�
spawn.wait�s����<�<�>�>��*�*�T�X�X�q�1�K�C��"�#H�I�I��.�.��0���
�<�<���� �K� �n�n�V�4�D�O� $�D��"�D�O������^�^�F�
#�
#� �K�"�D�O� "���F� 3�D��"�D�O������]�]�6�
"�
"�"�$I�J�
J����rc��UR(agUR(aSnO[Rn[R"UR
U5up#US:Xa+[R"UR
U5up#US:XagUS:Xag[R"U5(a0X0l
[R"U5UlSUlSUlg[R""U5(a0X0l
SUl[R$"U5UlSUlg[R&"U5(a[S5eg![aD [R"5SnUR[R:Xa[S5eUef=f![a/nUR[R:Xa[S5eeSnAff=f)	a:This 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. Frrz�isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process?z�isalive() encountered condition that should never happen. There was no child process. Did someone else call waitpid() on our process?NTz�isalive() encountered condition where child process is stopped. This is not supported. Is some other process attempting job control with our child pid?)r�r�r��WNOHANGrkr�r�r&r'�errno�ECHILDrrmr�rlr`r�rnrorp)r�waitpid_optionsr�r�r�rs      rr��
spawn.isalive�s����?�?���=�=�
 �O� �j�j�O�	��*�*�T�X�X��?�K�C� �!�8�
� �j�j����?�C��� �a�x���!�8��
�<�<���� �K� �n�n�V�4�D�O� $�D��"�D�O���^�^�F�
#�
#� �K�"�D�O� "���F� 3�D��"�D�O���]�]�6�
"�
"�"�$6�7�
7���o�		��,�,�.��#�C��y�y�E�L�L�(�&�(*�+�+�
�	�		��&�
��7�7�e�l�l�*�*�,.�/�/�
��
�s$�#E�"#F!�AF�!
G�+*G�Gc�r�UR5(a"[R"URU5 gg)z�This sends 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. N)r�r�rer�)r�sigs  rre�
spawn.kill�s&���<�<�>�>��G�G�D�H�H�c�"�rc��[SR[U5USRURVs/sHn[U5PM sn5S95es snf)Nz`got {badtype} ({badobj!r}) as pattern, must be one of: {goodtypes}, pexpect.EOF, pexpect.TIMEOUTz, )�badtype�badobj�	goodtypes)r]�formatr�r)rTr)r�pattern�asts   r�_pattern_type_err�spawn._pattern_type_errsg���I����W�
�'.�*.�)�)�/3�/H�/H�5J�/H��69��X�/H�5J�+K� �"��	��5Js�Ac	��Uc/$[U[5(dU/n[RnUR(aU[R
-n/n[
U5H�upE[XPR5(a8URU5nUR[R"XR55 MWU[LaUR[5 MwU[LaUR[5 M�[U[[R"S555(aURU5 M�URU5 M� U$)aThis compiles a pattern-string or a list of pattern-strings.
Patterns must be a StringType, EOF, TIMEOUT, SRE_Pattern, or a list of
those. Patterns may also be None which results in an empty list (you
might do this if waiting for an EOF or TIMEOUT condition without
expecting any pattern).

This is used by expect() when calling expect_list(). Thus expect() is
nothing more than::

     cpl = self.compile_pattern_list(pl)
     return self.expect_list(cpl, timeout)

If you are using expect() within a loop it may be more
efficient to compile the patterns first and then call expect_list().
This avoid calls in a loop to compile_pattern_list()::

     cpl = self.compile_pattern_list(my_pattern)
     while some_condition:
        ...
        i = self.expect_list(clp, timeout)
        ...
r)rRrNrrr��
IGNORECASE�	enumeraterTr�rUrrrr�r�)rrb�
compile_flags�compiled_pattern_list�idx�ps      r�compile_pattern_list�spawn.compile_pattern_lists���2���I��(�D�)�)� �z�H��	�	�
��?�?�)�B�M�M�9�M� "����)�F�C��!�6�6�7�7��.�.�q�1��%�,�,�R�Z�Z��-I�J��c��%�,�,�S�1��g��%�,�,�W�5��A�t�B�J�J�r�N�3�4�4�%�,�,�Q�/��&�&�q�)�*�%�$rc�H�URU5nURUX#5$)a�This seeks through the stream until a pattern is matched. The
pattern is overloaded and may take several types. The pattern can be a
StringType, EOF, a compiled re, or a list of any of those types.
Strings will be compiled to re types. This returns the index into the
pattern list. If the pattern was not a list this returns index 0 on a
successful match. This may raise exceptions for EOF or TIMEOUT. To
avoid the EOF or TIMEOUT exceptions add EOF or TIMEOUT to the pattern
list. That will cause expect to match an EOF or TIMEOUT condition
instead of raising an exception.

If you pass a list of patterns and more than one matches, the first
match in the stream is chosen. If more than one pattern matches at that
point, the leftmost in the pattern list is chosen. For example::

    # the input is 'foobar'
    index = p.expect(['bar', 'foo', 'foobar'])
    # returns 1('foo') even though 'foobar' is a "better" match

Please note, however, that buffering can affect this behavior, since
input arrives in unpredictable chunks. For example::

    # the input is 'foobar'
    index = p.expect(['foobar', 'foo'])
    # returns 0('foobar') if all input is available at once,
    # but returs 1('foo') if parts of the final 'bar' arrive late

After a match is found the instance attributes 'before', 'after' and
'match' will be set. You can see all the data read before the match in
'before'. You can see the data that was matched in 'after'. The
re.MatchObject used in the re match will be in 'match'. If an error
occurred then 'before' will be set to all the data read so far and
'after' and 'match' will be None.

If timeout is -1 then timeout will be set to the self.timeout value.

A list entry may be EOF or TIMEOUT instead of a string. This will
catch these exceptions and return the index of the list entry instead
of raising the exception. The attribute 'after' will be set to the
exception type. The attribute 'match' will be None. This allows you to
write code like this::

        index = p.expect(['good', 'bad', pexpect.EOF, pexpect.TIMEOUT])
        if index == 0:
            do_something()
        elif index == 1:
            do_something_else()
        elif index == 2:
            do_some_other_thing()
        elif index == 3:
            do_something_completely_different()

instead of code like this::

        try:
            index = p.expect(['good', 'bad'])
            if index == 0:
                do_something()
            elif index == 1:
                do_something_else()
        except EOF:
            do_some_other_thing()
        except TIMEOUT:
            do_something_completely_different()

These two forms are equivalent. It all depends on what you want. You
can also just expect the EOF if you are waiting for all output of a
child to finish. For example::

        p = pexpect.spawn('/bin/ls')
        p.expect(pexpect.EOF)
        print p.before

If you are trying to optimize for speed then see expect_list().
)r��expect_list)rr�r>r�r�s     rrQ�spawn.expect<s/��Z!%� 9� 9�'� B����� 5��+�	+rc�8�UR[U5X#5$)aDThis takes a list of compiled regular expressions and returns the
index into the pattern_list that matched the child output. The list may
also contain EOF or TIMEOUT(which are not compiled regular
expressions). This method is similar to the expect() method except that
expect_list() does not recompile the pattern list on every call. This
may help if you are trying to optimize for speed, otherwise just use
the expect() method.  This is called by expect(). If timeout==-1 then
the self.timeout value is used. If searchwindowsize==-1 then the
self.searchwindowsize value is used. )�expect_loop�searcher_re)r�pattern_listr>r�s    rr��spawn.expect_list�s!������L� 9��+�	+rc�4^�[UTR5(dU[[4;aU/nU4Sjn[	U5nUVs/sH
oT"U5PM nnTR[U5X#5$![
a TR
U5 NOf=fs snf)aThis is similar to expect(), but uses plain string matching instead
of compiled regular expressions in 'pattern_list'. The 'pattern_list'
may be a string; a list or other sequence of strings; or TIMEOUT and
EOF.

This call might be faster than expect() for two reasons: string
searching is faster than RE matching and it is possible to limit the
search to just the end of the input buffer.

This method is also useful when you don't want to have to worry about
escaping regular expression characters that you want to match.c�>�U[[4;aU$[UTR5(aTR	U5$TRU5 gr)rrrRrTr�r�)r�rs �r�prepare_pattern�+spawn.expect_exact.<locals>.prepare_pattern�sF����7�C�.�(����'�4�#<�#<�=�=��1�1�'�:�:��"�"�7�+r)	rRrTrrr"r]r�r��searcher_string)rr�r>r�r�r�s`     r�expect_exact�spawn.expect_exact�s����
�|�T�%>�%>�?�?���#��.�(�>�L�	,�	1���-�L�5A�A�L�q���*�L��A������ =��+�	+���	1��"�"�<�0�	1��As�A4�B�4B�Bc�n�XlUS:XaURnUb[R"5U-nUS:XaURnURn[U5nUR
XVU5nUS:�agXQRSUlUSURUl	XQRURUl
URUlXplUR$UbUS:a[S5eURURU5n[U5n[R "S5 XX-nUbW[R"5-
nM�!["a� [$R&"5Sn	UR)5UlWUl	["Ul
UR*nUS:�a["UlXplURs$SUlSUl[#[-U	5S-[-U5-5e[a� [$R&"5Sn	WUlXPl	[Ul
UR.nUS:�a[UlXplURs$SUlSUl[[-U	5S-[-U5-5e WUl	SUl
SUlSUle=f)z�This is the common loop used inside expect. The 'searcher' should be
an instance of searcher_re or searcher_string, which describes how and
what to search for in the input.

See expect() for other arguments, return value and exceptions. rKNrz!Timeout exceeded in expect_any().g-C��6?rr�)r�r>r�r�rr�len�search�end�startrVrSr�r�rrrMr�rr&r'r^�	eof_indexr�
timeout_index)
rr�r>r�r��incoming�freshlenrfrlr�s
          rr��spawn.expect_loop�sd��!�
��b�=��l�l�G����y�y�{�W�,�H��r�!�#�4�4��8	��{�{�H��8�}�H�� ����<L�M���A�:�"*�<�<�=�"9�D�K�"*�+;�X�^�^�"<�D�K�!)�.�.�(�,�,�!G�D�J�!)���D�J�',�$��+�+�+��'�g��k�!�"E�F�F��)�)�$�,�,��@���q�6���
�
�6�"�#�<���&�&�����4�G�'��(�
	7��,�,�.��#�C��*�*�,�D�K�"�D�K��D�J��&�&�E���z� ��
�#(� ��'�'�'�!��
�#'�� ��#�c�(�T�/�C��I�5�6�6��
	;��,�,�.��#�C�"�D�K�"�K� �D�J��*�*�E���z�$��
�#(� ��'�'�'�!��
�#'�� ��c�#�h��o��D�	�9�:�:�	�"�D�K��D�J��D�J�#�D���s#�BE�A2E�A8J4�
BJ4�%AJ4c���[[SS5n[R"SSSSS5n[R
"URX5n[R"SU5SS$)zeThis returns the terminal window size of the child tty. The return
value is a tuple of (rows, cols). �
TIOCGWINSZiht@�HHHHrr#)�getattrr��struct�pack�fcntl�ioctlr��unpack)rr�r��xs    r�
getwinsize�spawn.getwinsizesT��
�W�l�J�?�
��K�K���1�a��+���K�K��
�
�z�5���}�}�V�Q�'��!�,�,rc��[[SS5nUS:XaSn[R"SXSS5n[R
"UR
5X45 g)aThis sets 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. �
TIOCSWINSZigt�lgtr�rN)r�r�r�r�r�r�r�)r�rows�colsr�r�s     rr��spawn.setwinsizesG�� �W�l�K�@�
���#�$�J��K�K���A�q�1��
���D�K�K�M�:�1rrAc�@�URUR5 URR5 UR	5Ul[
R"UR5n[
R"UR5 [(aURS5nURXU5 [
R"UR[
RU5 g![
R"UR[
RU5 f=f)a�This gives control of the child process to the interactive user (the
human at the keyboard). Keystrokes are sent to the child process, and
the stdout and stderr output of the child process is printed. This
simply echos the child stdout and child stderr to the real stdout and
it echos the real stdin to the child stdin. When the user types the
escape_character this method will stop. The default for
escape_character is ^]. This should not be confused with ASCII 27 --
the ESC character. ASCII 29 was chosen for historical merit because
this is the character used by 'telnet' as the escape character. The
escape_character will not be sent to the child process.

You may pass in optional input and output filter functions. These
functions should take a string and return a string. The output_filter
will be passed all the output from the child process. The input_filter
will be passed all the keyboard input from the user. The input_filter
is run BEFORE the check for the escape_character.

Note that if you change the window size of the parent the SIGWINCH
signal will not be passed through to the child. If you want the child
window size to change when the parent's window size changes then do
something like the following example::

    import pexpect, struct, fcntl, termios, signal, sys
    def sigwinch_passthrough (sig, data):
        s = struct.pack("HHHH", 0, 0, 0, 0)
        a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(),
            termios.TIOCGWINSZ , s))
        global p
        p.setwinsize(a[0],a[1])
    # Note this 'p' global and used in sigwinch_passthrough.
    p = pexpect.spawn('/bin/bash')
    signal.signal(signal.SIGWINCH, sigwinch_passthrough)
    p.interact()
zlatin-1N)rwrrr[r\r^�ttyr�r��setraw�PY3r��_spawn__interact_copyr�	TCSAFLUSH)r�escape_character�input_filter�
output_filter�modes     r�interact�spawn.interact*s���N	
���T�[�[�)��������&�&�(����}�}�T�.�.�/���
�
�4�$�$�%��3�/�6�6�y�A��	B�� � �!1��O��M�M�$�+�+�S�]�]�D�A��C�M�M�$�+�+�S�]�]�D�A�s�(C+�+2Dc��US:waOUR5(a9[R"X5nX#SnUS:waUR5(aM7gggg)�/This is used by the interact() method.
        rN)r�r�rs)rr��datar8s    r�__interact_writen�spawn.__interact_writen]sE���c�k�d�l�l�n�n�����"�A���8�D��c�k�d�l�l�n�n�k�n�krc�0�[R"US5$)r�i�)r�r)rr�s  r�__interact_read�spawn.__interact_reades���w�w�r�4� � rc��UR5(GarURURUR///5upEnURU;a�UR	UR5nU(aU"W5nURb5URRW5 URR5 [R"URW5 URU;aUR	UR5nU(aU"U5nURU5nUS:wa"USUnURURU5 gURURU5 UR5(aGMqgg![
a*nUR[R:waeSnAGNJSnAff=f)r�NrK)r�rr�r��_spawn__interact_readr�ru�EIOrBrsr\r�r��rfind�_spawn__interact_writen)	rr�r�r�rrrr�r�s	         r�__interact_copy�spawn.__interact_copyks\���l�l�n�n��m�m�T�]�]�D�4E�4E�$F��B�O�G�A�!��}�}��!���/�/��
�
�>�D�
!�(��.�D��<�<�+��L�L�&�&�t�,��L�L�&�&�(�����+�+�T�2�� � �A�%��+�+�D�,=�,=�>���'��-�D��J�J�/�0����7����8�D��*�*�4�=�=�$�?���&�&�t�}�}�d�;�1�l�l�n�n��
���w�w�%�)�)�+��,���s�F
�

F>�F9�9F>c�`�Ub[R"5U-n[R"XX45$![Rab [R"5SnUR
[
R:Xa*Ub%W[R"5-
nUS:a///4s$Oef=fM�)z�This is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). rr)r��select�errorr&r'ru�EINTR)r�iwtd�owtd�ewtdr>r�r�s       r�__select�spawn.__select�s������y�y�{�W�,�H��
��}�}�T��?�?���<�<�
��l�l�n�Q�'���9�9����+��*�"*�T�Y�Y�[�"8��"�Q�;�#%�r�2�,�.���
��s�5�A0B+�)B+c��[S5e)zgThis method is no longer supported or allowed. I don't like getters
and setters without a good reason. zbThis method is no longer supported or allowed. Just assign a value to the maxread member variable.�r)rrMs  r�
setmaxread�spawn.setmaxread�s��
� +�,�	,rc��[S5e)z7This method is no longer supported or allowed.
        zbThis method is no longer supported or allowed. Just assign a value to the logfile member variable.r�)r�
fileobjects  r�setlog�spawn.setlog�s��
� #�$�	$r)(r�r�r��__irix_hackrSr�rVrrr�r�rGrCr�r�r�r�rDr`r�r�r�rBr�r�r�r�rMr�r�r�r�r�r�r�r�r�r[r�r>r�)T)rK)rrK)r)F)rKrK)NNNr)Hr.r/r0r1r2rkr^r�rrT�staticmethodrmr�r7r�rw�
basestring�chrr&r[rs�encodingrr�r�r�r�r rEr�r�r�r_r\r�r�r�rrrrrr#r)r/rWr2r9rSr[r_rbr�rqr�rer�r�rQr�r�r�r�r�r�r�r�r�rr�r�r3r8rrrrs���(��K�
� %�s�|��	�	�
�	��*�*�#�#�G�,��	�	F�
�	F�!+�}���C� ���*�*���*�*�*�*���H�%'��T��t��4��v'�p����
����
�����"�B$&�Y�v$�L,�\�
�&
�(��<�'@�R�K?�Z�:�*7�
� ��
�*��-�6 #�D
#��'�R�<M�^#��/%�bO+�b
+�+�BI�V-�2�0),�B���T�1B�f�!�04�-1�<�@�>,�$rrc�^�\rSrSrSr\(a\r\4r\	"\
5r\Rr
O(\r\4r\	"\5r\RR!S5r
\R$R&rU4Sjr\	S5r\	S5rSrSrS	rU=r$)
r	i�afWorks like spawn, but accepts and returns unicode strings.

Extra parameters:

:param encoding: The encoding to use for communications (default: 'utf-8')
:param errors: How to handle encoding/decoding errors; one of 'strict'
               (the default), 'ignore', or 'replace', as described
               for :meth:`~bytes.decode` and :meth:`~str.encode`.
roc��>�URSS5UlURSS5Ul[R"UR5"URS9Ul[[U]""U0UD6 g)Nr�r��errors�strict)r�)	�popr�r��codecs�getincrementaldecoder�_decoderrr	r)rr�rIrs   �rr�spawnu.__init__�sZ����
�
�:�w�7��
��j�j��8�4����4�4�T�]�]�C�4�;�;�W��
�
�f�d�$�d�5�f�5rc��U$rr8r�s rr��spawnu._coerce_expect_string�r�rc��U$rr8r�s rr��spawnu._coerce_send_string�r�rc�6�URRUSS9$)NF)�final)r�rur�s  rr��spawnu._coerce_read_string�s���}�}�#�#�A�U�#�3�3rc��[R"URURURUR
55$r)r�rsr�r�r�r�r�s  rr2�spawnu._send�s*���x�x��
�
�q�x�x��
�
�t�{�{�'K�L�Lr)r�r�r�)r.r/r0r1r2r�rr^rTr�r�rmr�r7�unicode�unichrrur&r[rsrwrr�r�r�r2r3r4r5s@rr	r	�s�������� #�w���C� ���*�*���� '�{���F�#���*�*�#�#�G�,���j�j�&�&�O�6���������4�M�Mrr	c�.�\rSrSrSrSrSrSSjrSrg)	r�i�aThis is a plain string search helper for the spawn.expect_any() method.
This helper class is for speed. For more powerful regex patterns
see the helper class, searcher_re.

Attributes:

    eof_index     - index of EOF, or -1
    timeout_index - index of TIMEOUT, or -1

After a successful match by the search() method the following attributes
are available:

    start - index into the buffer, first byte of match
    end   - index into the buffer, first byte after match
    match - the matching string itself

c���SUlSUl/Ul[U5HCup#U[LaX lMU[
LaX lM'URR
X#45 ME g)z�This creates an instance of searcher_string. This argument 'strings'
may be a list; a sequence of strings; or the EOF or TIMEOUT types. rKN)r�r��_stringsr�rrrU)r�stringsr8r�s    rr�searcher_string.__init__s^��
��������
��g�&�D�A��C�x�!"����G�|�%&�"���M�M� � �!��(�'rc���URVs/sHoSSU-4PM nnURS5 URS:�a*URURSUR-45 URS:�a*URURSUR-45 UR	5 [[
U65SnSRU5$s snf)�MThis returns a human-readable string that represents the state of
the object.rz    %d: "%s")rKzsearcher_string:�    %d: EOF�    %d: TIMEOUTrr�)r�rUr�r��sortrN�zipr))r�ns�sss   rr �searcher_string.__str__s���
6:�]�]�
C�]�r�!�u�n�r�)�*�]��
C�
�	�	�*�+��>�>�Q���I�I�t�~�~�}�t�~�~�'E�F�G�����"��I�I�t�)�)�!�D�$6�$6�6�8�
9�
���	�
�#�r�(�^�A�
���y�y��}���Ds�CNc��SnURHBupVUcU[U5-*nOU*nURXg5nUS:�dM4UbX�:dM>UnXVp�MD UcgW
UlX@lUR[UR5-UlW	$)a�This searches 'buffer' for the first occurence of one of the search
strings.  'freshlen' must indicate the number of bytes at the end of
'buffer' which have not been searched before. It helps to avoid
searching the same, possibly big, buffer over and over again.

See class spawn for the 'searchwindowsize' argument.

If there is a match this returns the index of that string, and sets
'start', 'end' and 'match'. Otherwise, this returns -1. NrrK)r�r�r�r�r�r�)rrrr�r��first_matchrfr��offsetr8�
best_index�
best_matchs           rr��searcher_string.search!s������
�
�H�E��'�$�c�!�f�,�-��+�*�����A�&�A��A�v�;�.�!�/���).�J�&������
� �
��:�:��D�J�J��/����r)r�r�r�r�r�r�r�	r.r/r0r1r2rr r�r3r8rrr�r��s���$)�"� +rr�c�.�\rSrSrSrSrSrSSjrSrg)	r�iOa)This is regular expression string search helper for the
spawn.expect_any() method. This helper class is for powerful
pattern matching. For speed, see the helper class, searcher_string.

Attributes:

    eof_index     - index of EOF, or -1
    timeout_index - index of TIMEOUT, or -1

After a successful match by the search() method the following attributes
are available:

    start - index into the buffer, first byte of match
    end   - index into the buffer, first byte after match
    match - the re.match object returned by a succesful re.search

c	�
�SUlSUl/Ul[[	[[
U555U5HCup#U[LaX lMU[LaX lM'URRX#45 ME g)z�This creates an instance that searches for 'patterns' Where
'patterns' may be a list or other sequence of compiled regular
expressions, or the EOF or TIMEOUT types.rKN)
r�r��	_searchesrrNr�r�rrrU)rrbr8r�s    rr�searcher_re.__init__csn�������������U�3�x�=�1�2�H�=�D�A��C�x�!"����G�|�%&�"���N�N�!�!�1�&�)�>rc�^�[5nURH'up#URUSX#R4-45 M) URS5 UR
S:�a*URUR
SUR
-45 URS:�a*URURSUR-45 UR5 [[U65SnSRU5$![a& URUSX#R4-45 GMf=f)	rz    %d: re.compile("%s")z    %d: re.compile(%r))rKzsearcher_re:rrrrr�)
rNrrUr��UnicodeEncodeErrorr�r�rrr))rr	r8r�s    rr �searcher_re.__str__us
���V���N�N�D�A�
J��	�	�1�8�A�y�y�>�I�J�K�#�	�	�	�&�'��>�>�Q���I�I�t�~�~�}�t�~�~�'E�F�G�����"��I�I�t�)�)�+<��"�"�,#�$�
%�
���	�
�#�r�(�^�A�
���y�y��}���&�
J��	�	�1�6�!�Y�Y��G�H�I�I�	
J�s�!C<�<+D,�+D,Nc�<�SnUcSnO[S[U5U-
5nURH;upgURX5nUcMUR	5n	UbX�:dM5U	nUn
UnM= UcgX@lW
UlUR
R
5UlW$)ahThis searches 'buffer' for the first occurence of one of the regular
expressions. 'freshlen' must indicate the number of bytes at the end of
'buffer' which have not been searched before.

See class spawn for the 'searchwindowsize' argument.

If there is a match this returns the index of that string, and sets
'start', 'end' and 'match'. Otherwise, returns -1.NrrK)�maxr�rr�r�r�r�)rrrr�r�r�searchstartrfr�r�r8�	the_matchrs            rr��searcher_re.search�s������#��K��a��V��/?�!?�@�K����H�E��H�H�V�1�E��}�����
�A��"�a�o���!�	�"�
�'���� �
���
��:�:�>�>�#����r)rr�r�r�r�r�rrr8rrr�r�Os���$*�$�4 rr�c�*�[RRU5S:wa,[R"U[R5(aU$S[R
;d[R
SS:Xa[RnO[R
SnUR[R5nUHPn[RRX05n[R"U[R5(dMNUs $ g)z�This takes a given filename; tries to find it in the environment path;
then checks if it is executable. This returns the full path to the filename
if found and executable. Otherwise this returns None.r�PATHN)
r��path�dirname�access�X_OK�environ�defpath�split�pathsepr))�filenamer��pathlistr �ffs     rrr�s���
�w�w���x� �B�&�
�9�9�X�r�w�w�'�'��O�
�R�Z�Z��2�:�:�f�#5��#;��J�J���J�J�v����w�w�r�z�z�"�H���
�W�W�\�\�$�
)��
�9�9�R����!�!��I��rc��/nSnSnSnSnSnSnUnUH�n	X�:XdX�:XaYU	S:XaUnMU	S:XaUnM!U	S	:XaUnM+U	R5(aX�:XaMGURU5 SnUnM^X)-nUnMfX�:XaX)-nUnMsX�:XaU	S:XaUnM�X)-nM�X�:XdM�U	S	:XaUnM�X)-nM� US:waURU5 U$)
a
This splits a command line into a list of arguments. It splits arguments
on spaces, but handles embedded quotes, doublequotes, and escaped
characters. It's impossible to do this with a regular expression, so I
wrote a little state machine to parse the command line. rrrr#rrXrH�'�")�isspacerU)
�command_line�arg_list�arg�state_basic�	state_esc�state_singlequote�state_doublequote�state_whitespacerrls
          rr
r
�s���H�
�C��K��I��������E�
����5�#<��D�y�!���d��)���d��)��������,���O�O�C�(��C�,�E��g��#��
�
��'�C��E�
�
'��D�y�#���g��
�
'��D�y�#���g��G�J�b�y�������Or)rKFNNNNN))r2r�r&r�r�rr�r�rXr�r�r�r�rur$r�r��dont_write_bytecode�ImportErrorr'r�rrr�__all__�version_infor��	Exceptionrrrr
rrF�objectrr	r�r�rr
r8rr�<module>r=sH��?�BE�
����
������������"�C������I�������a����y��,0�
�0�
8��8�;?�59�K'�Z<@�59�	2�1�fd$�F�d$�T-)M�U�)M�X`�f�`�F`�&�`�F�,:��i;�E�

�,�,�.��
�C�
�c�#�h�"D�D�E�E�E�s�AC
�
,C6

Filemanager

Name Type Size Permission Actions
__init__.cpython-313.pyc File 83.48 KB 0644
Filemanager