a ÿé!^’ã@sÆddlZddlZddlZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl m Z mZmZddlmZddlmZmZmZmZedd „ƒZejdd kZGd d „d eƒZd d„ZdS)éN)Úcontextmanager)Úuse_native_pty_forké)ÚExceptionPexpectÚEOFÚTIMEOUT)Ú SpawnBase)ÚwhichÚsplit_command_lineÚselect_ignore_interruptsÚpoll_ignore_interruptsc cs@z dVWn0tjy:}zt|jŽ‚WYd}~n d}~00dS)z;Turn ptyprocess errors into our own ExceptionPexpect errorsN)Ú ptyprocessZPtyProcessErrorrÚargs)Úe©rú5/usr/lib/python3.9/site-packages/pexpect/pty_spawn.pyÚ_wrap_ptyprocess_errs récs`eZdZdZeZgdddddddddddddf‡fdd „ Zd d „Zgddfd d „Zdd„ZdIdd„Z dd„Z dJdd„Z dd„Z dd„Z dK‡fdd„ Zdd„Zd d!„Zd"d#„ZdLd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zed/d0„ƒZejd1d0„ƒZd2d3„ZdMd4d5„Zd6d7„Zd8d9„Zd:d;„Zdd?„Z e!d@ƒddfdAdB„Z"dCdD„Z#dEdF„Z$dNdGdH„Z%‡Z&S)OÚspawnzjThis is the main class interface for Pexpect. Use this class to start and control child applications. éiÐNFTÚstrictcsštt|ƒj||||| | dtj|_tj|_tj|_d|_||_||_ | |_ | |_ t j  ¡ d¡|_|dur€d|_d|_d|_n| ||| |¡||_dS)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 user@example.com') 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', ['user@example.com']) 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. When the keyword argument *searchwindowsize* is None (default), the full buffer is searched at each iteration of receiving incoming data. The default number of bytes scanned at each iteration is very large and may be reduced to collaterally reduce search cost. After :meth:`~.expect` returns, the full buffer attribute remains up to size *maxread* irrespective of *searchwindowsize* value. When the keyword argument ``timeout`` is specified as a number, (default: *30*), then :class:`TIMEOUT` will be raised after the value specified has elapsed, in seconds, for any of the :meth:`~.expect` family of method calls. When None, TIMEOUT will not be raised, and :meth:`~.expect` may block indefinitely until match. 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 = open('mylog.txt','wb') child.logfile = fout Example log to stdout:: # In Python 2: child = pexpect.spawn('some_command') child.logfile = sys.stdout # In Python 3, we'll use the ``encoding`` argument to decode data # from the subprocess and handle it as unicode: child = pexpect.spawn('some_command', encoding='utf-8') 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 You will need to pass an encoding to spawn in the above code if you are using Python 3. To separately log output sent to the child use logfile_send:: child.logfile_send = fout If ``ignore_sighup`` is True, the child process will ignore SIGHUP signals. The default is False from Pexpect 4.0, meaning that SIGHUP will be handled normally by the child. 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 None to return to the old behavior. 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:: child = pexpect.spawn('some_command') child.close() print(child.exitstatus, child.signalstatus) 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. The echo attribute may be set to False to disable echoing of input. As a pseudo-terminal, all input echoed by the "keyboard" (send() or sendline()) will be repeated to output. For many cases, it is not desirable to have echo enabled, and it may be later disabled using setecho(False) followed by waitnoecho(). However, for some platforms such as Solaris, this is not possible, and should be disabled immediately on spawn. If preexec_fn is given, it will be called in the child process before launching the given command. This is useful to e.g. reset inherited signal handlers. The dimensions attribute specifies the size of the pseudo-terminal as seen by the subprocess, and is specified as a two-entry tuple (rows, columns). If this is unspecified, the defaults in ptyprocess will apply. The use_poll attribute enables using select.poll() over select.select() for socket handling. This is handy if your system could have > 1024 fds )ÚtimeoutÚmaxreadÚsearchwindowsizeÚlogfileÚencodingÚ codec_errorsédZirixNz)ÚsuperrÚ__init__ÚptyÚ STDIN_FILENOÚ STDOUT_FILENOZ STDERR_FILENOÚstr_last_charsÚcwdÚenvÚechoÚ ignore_sighupÚsysÚplatformÚlowerÚ startswithÚ_spawn__irix_hackÚcommandrÚnameÚ_spawnÚuse_poll)Úselfr-rrrrrr$r%r'r&Ú preexec_fnrrÚ dimensionsr0©Ú __class__rrr$s&ÿzspawn.__init__cCsg}| t|ƒ¡| dt|jƒ¡| d|jf¡| d|j|j|j d…f¡| d|j|jr||j|j d…ndf¡| d|jf¡| d|j f¡| d t|j ƒ¡| d t|j ƒ¡t |d ƒrð| d t|j ƒ¡| d t|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡| dt|jƒ¡d |¡S)zVThis returns a human-readable string that represents the state of the object. z command: zargs: %rzbuffer (last %s chars): %rNzbefore (last %s chars): %rÚz after: %rz match: %rz match_index: z exitstatus: Úptyprocz flag_eof: zpid: z child_fd: zclosed: z timeout: z delimiter: z logfile: zlogfile_read: zlogfile_send: z maxread: z ignorecase: zsearchwindowsize: zdelaybeforesend: zdelayafterclose: zdelayafterterminate: Ú )ÚappendÚreprÚstrr-rr#ÚbufferÚbeforeZafterÚmatchZ match_indexÚ exitstatusÚhasattrÚflag_eofÚpidÚchild_fdÚclosedrZ delimiterrZ logfile_readZ logfile_sendrZ ignorecaserÚdelaybeforesendZdelayaftercloseÚdelayafterterminateÚjoin©r1ÚsrrrÚ__str__Ðs6", z spawn.__str__cs„t|tdƒƒrtdƒ‚t|tgƒƒs,tdƒ‚|gkrLt|ƒˆ_ˆjdˆ_n"|dd…ˆ_ˆj d|¡|ˆ_tˆjˆj d}|dur˜tddˆjƒ‚|ˆ_ˆjˆjd<dd   ˆj¡d ˆ_ ˆj dusÒJd ƒ‚ˆjdusäJd ƒ‚ˆj ˆd œ}ˆjr ‡fdd„}||d<|dur||d<ˆjdur@‡fdd„ˆjDƒˆ_ˆjˆjfˆj ˆjdœ|¤Žˆ_ˆjj ˆ_ ˆjjˆ_dˆ_dˆ_dS)aThis 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.N)r%z%The command was not found or was not zexecutable: %s.ú<ú ú>zThe pid member must be None.z$The command member must not be None.)r&r2cs"t tjtj¡ˆdurˆƒdS)z7Set SIGHUP to be ignored, then call the real preexec_fnN)ÚsignalÚSIGHUPÚSIG_IGNr)r2rrÚpreexec_wrapper sz%spawn._spawn..preexec_wrapperr2r3cs&g|]}t|tƒr|n | ˆj¡‘qSr)Ú isinstanceÚbytesÚencoder)Ú.0Úa©r1rrÚ ,sÿz spawn._spawn..)r%r$F)rRÚtyperÚ TypeErrorr rr-Úinsertr r%rGr.rBr&r'rÚ _spawnptyr$r7ÚfdrCÚ terminatedrD)r1r-rr2r3Zcommand_with_pathÚkwargsrQr)r2r1rr/ðsN ÿ      ÿÿÿ  z spawn._spawncKstjj|fi|¤ŽS)z1Spawn a pty and return an instance of PtyProcess.)r Z PtyProcessr)r1rr_rrrr\9szspawn._spawnptycCsT| ¡tƒ|jj|dWdƒn1s20Y| ¡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). )ÚforceNéÿÿÿÿT)Úflushrr7ÚcloseÚisaliverCrD©r1r`rrrrc=s ,z spawn.closecCs t |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. )ÚosÚisattyrCrWrrrrgMs z spawn.isattyracCsf|dkr|j}|dur"t ¡|}| ¡s.dS|dkrB|durBdS|durV|t ¡}t d¡q"dS)aThis 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==-1 then this method will use the value in self.timeout. If timeout==None then this method to block until ECHO flag is False. raNTrFgš™™™™™¹?)rÚtimeÚgetechoÚsleep)r1rZend_timerrrÚ waitnoechoXs  zspawn.waitnoechocCs |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. )r7rirWrrrrivsz spawn.getechocCs |j |¡S)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. )r7Úsetecho)r1Ústaterrrrl~s z spawn.setechorcslˆjrtdƒ‚ˆjr"‡fdd„}n ‡fdd„}|dƒrÂzttˆƒ |¡}Wntyfˆ ¡‚Yn0t|ƒ|kr¾|dƒr¾z |ttˆƒ |t|ƒ¡7}Wqhtyºˆ ¡|YS0qh|S|dkrЈj }ˆ ¡s|dƒròttˆƒ |¡Sdˆ_ tdƒ‚n ˆj r"|d ur"|d kr"d }|dkrF||ƒrFttˆƒ |¡Sˆ ¡s`dˆ_ td ƒ‚nt d ƒ‚d S) azThis 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 logfile is specified, a copy is written to that log. 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 affected 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. On the other hand, if there are bytes available to read immediately, all those bytes will be read (up to the buffer size). So, if the buffer size is 1 megabyte and there is 1 megabyte of data available to read, the buffer will be filled, regardless of timeout. This is a wrapper around os.read(). It uses select.select() or select.poll() to implement the timeout. zI/O operation on closed file.cstˆjg|ƒS©N)r rC©rrWrrÚselect¾sz&spawn.read_nonblocking..selectcstˆjggg|ƒdS)Nr)r rCrorWrrrpÁsrraTz&End Of File (EOF). Braindead platform.Néz&End of File (EOF). Very slow platform.zTimeout exceeded.) rDÚ ValueErrorr0rrÚread_nonblockingrrdÚlenrrAr,r)r1ÚsizerrpZincomingr4rWrrs sD         zspawn.read_nonblockingcCs| |¡dS)zHThis is similar to send() except that there is no return value. N)ÚsendrHrrrÚwritesz spawn.writecCs|D]}| |¡qdS)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)rw)r1ZsequencerIrrrÚ writelinesszspawn.writelinescCsJ|jdurt |j¡| |¡}| |d¡|jj|dd}t |j |¡S)aù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. The default terminal input mode is canonical processing unless set otherwise by the child process. This allows backspace and other line processing to be performed prior to transmitting to the receiving program. As this is buffered, there is a limited size of such buffer. On Linux systems, this is 4096 (defined by N_TTY_BUF_SIZE). All other systems honor the POSIX.1 definition PC_MAX_CANON -- 1024 on OSX, 256 on OpenSolaris, and 1920 on FreeBSD. This value may be discovered using fpathconf(3):: >>> from os import fpathconf >>> print(fpathconf(0, 'PC_MAX_CANON')) 256 On such a system, only 256 bytes may be received per line. Any subsequent bytes received will be discarded. BEL (``''``) is then sent to output if IMAXBEL (termios.h) is set by the tty driver. This is usually enabled by default. Linux does not honor this as an option -- it behaves as though it is always set on. Canonical input processing may be disabled altogether by executing a shell, then stty(1), before executing the final program:: >>> bash = pexpect.spawn('/bin/bash', echo=False) >>> bash.sendline('stty -icanon') >>> bash.sendline('base64') >>> bash.sendline('x' * 5000) NrvF)Úfinal) rErhrjÚ_coerce_send_stringÚ_logZ_encoderrTrfrwrC)r1rIÚbrrrrvs #    z spawn.sendr6cCs| |¡}| ||j¡S)aWraps send(), sending string ``s`` to child process, with ``os.linesep`` automatically appended. Returns number of bytes written. Only a limited number of bytes may be sent for each line in the default terminal mode, see docstring of :meth:`send`. )rzrvÚlineseprHrrrÚsendline;s zspawn.sendlinecCs(|jdur| |jd¡}| |d¡dS)z5Write control characters to the appropriate log filesNÚreplacerv)rÚdecoder{rHrrrÚ _log_controlDs zspawn._log_controlcCs|j |¡\}}| |¡|S)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(). )r7Ú sendcontrolr)r1ÚcharÚnÚbyterrrr‚Js  zspawn.sendcontrolcCs|j ¡\}}| |¡dS)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. N)r7Úsendeofr©r1r„r…rrrr†Ws z spawn.sendeofcCs|j ¡\}}| |¡dS)znThis sends a SIGINT to the child. It does not require the SIGINT to be the first character on a line. N)r7Úsendintrrr‡rrrrˆdszspawn.sendintrcCs|jjSrn©r7rArWrrrrAkszspawn.flag_eofcCs ||j_dSrnr‰)r1ÚvaluerrrrAoscCs|jS)z@This returns True if the EOF exception was ever raised. )rArWrrrÚeofssz spawn.eofcCsì| ¡s dSz¨| tj¡t |j¡| ¡s4WdS| tj¡t |j¡| ¡sZWdS| tj¡t |j¡| ¡s€WdS|r°| tj ¡t |j¡| ¡sªWdSWdSWdSt yæt |j¡| ¡sÜYdSYdSYn0dS)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) rdÚkillrNrOrhrjrFÚSIGCONTÚSIGINTÚSIGKILLÚOSErrorrerrrÚ terminatexs6          zspawn.terminatecCsV|j}tƒ| ¡}Wdƒn1s*0Y|j|_|j|_|j|_d|_|S)a@This 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. This method is non-blocking if :meth:`wait` has already been called previously or :meth:`isalive` method returns False. It simply returns the previously determined exit status. NT)r7rÚwaitÚstatusr?Ú signalstatusr^)r1r7r?rrrr’ s &z spawn.waitcCsZ|j}tƒ| ¡}Wdƒn1s*0Y|sV|j|_|j|_|j|_d|_|S)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. NT)r7rrdr“r?r”r^)r1r7Úaliverrrrd¸s&z spawn.isalivecCs| ¡rt |j|¡dS)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)rdrfrŒrB)r1ZsigrrrrŒËsz spawn.killcCs |j ¡S)zmThis returns the terminal window size of the child tty. The return value is a tuple of (rows, cols). )r7Ú getwinsizerWrrrr–Õszspawn.getwinsizecCs|j ||¡S)a=This 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. )r7Ú setwinsize)r1ZrowsZcolsrrrr—Úszspawn.setwinsizeéc CsŒ| |j¡|j ¡| ¡|_t |j¡}t  |j¡|durNt rN|  d¡}z$|  |||¡Wt  |jtj|¡nt  |jtj|¡0dS)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 return None. The escape_character will not be transmitted. The default for escape_character is entered as ``Ctrl - ]``, the very same as BSD telnet. To prevent escaping, escape_character may be set to None. If a logfile is specified, then the data sent and received from the child process in interact mode is duplicated to the given log. You may pass in optional input and output filter functions. These functions should take bytes array and return bytes array too. Even with ``encoding='utf-8'`` support, meth:`interact` will always pass input_filter and output_filter bytes. You may need to wrap your function to decode and encode back to UTF-8. 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)) if not p.closed: p.setwinsize(a[0],a[1]) # Note this 'p' is global and used in sigwinch_passthrough. p = pexpect.spawn('/bin/bash') signal.signal(signal.SIGWINCH, sigwinch_passthrough) p.interact() Nzlatin-1)Zwrite_to_stdoutr<ÚstdoutrbZ buffer_typeÚ_bufferÚttyZ tcgetattrr!ZsetrawÚPY3rTÚ_spawn__interact_copyZ tcsetattrZ TCSAFLUSH)r1Úescape_characterÚ input_filterÚ output_filterÚmoderrrÚinteractãs.       zspawn.interactcCs.|dkr*| ¡r*t ||¡}||d…}qdS)ú/This is used by the interact() method. óN)rdrfrw)r1r]Údatar„rrrZ__interact_writens zspawn.__interact_writencCs t |d¡S)r£iè)rfÚread)r1r]rrrZ__interact_read%szspawn.__interact_readc Csb| ¡r^|jr"t|j|jgƒ}nt|j|jgggƒ\}}}|j|vrÎz| |j¡}WnDtyš}z,|jdt j kr„WYd}~q^‚WYd}~n d}~00|dkr¨q^|r´||ƒ}|  |d¡t   |j|¡|j|vr| |j¡}|rð||ƒ}d} |dur| |¡} | dkrB|d| …}|r0|  |d¡| |j|¡q^|  |d¡| |j|¡qdS)r£rNr¤r¦rarv)rdr0r rCr!r Ú_spawn__interact_readrrÚerrnoZEIOr{rfrwr"ÚrfindÚ_spawn__interact_writen) r1ržrŸr ÚrÚwrr¥ÚerrÚirrrZ__interact_copy+sD ÿ           zspawn.__interact_copy)T)ra)rra)r6)F)NNN)'Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrJr/r\rcrgrkrirlrsrwrxrvr~rr‚r†rˆÚpropertyrAÚsetterr‹r‘r’rdrŒr–r—Úchrr¢rªr§rÚ __classcell__rrr4rrsXü- I  "` ,      (  ÿ :ÿrcOs| dd¡t|i|¤ŽS)z-Deprecated: pass encoding to spawn() instead.rzutf-8)Ú setdefaultr)rr_rrrÚspawnuYs r¸)rfr(rhr r›r¨rNÚ contextlibrr Zptyprocess.ptyprocessrÚ exceptionsrrrZ spawnbaserZutilsr r r r rÚ version_inforœrr¸rrrrÚs.    B