PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  Ɵ[c@sqdZddlmZddlmZmZddlmZmZddl Z dgZ defdYZ dS( szThis is like pexpect, but it will work with any file descriptor that you pass it. You are responsible for opening and close the file descriptor. This allows you to use Pexpect with sockets and named pipes (FIFOs). 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 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. i(t SpawnBase(tExceptionPexpecttTIMEOUT(tselect_ignore_interruptstpoll_ignore_interruptsiNtfdspawnc BseZdZdddddddedZdZdZedZdZ d Z d Z d Z d d dZ RS(sThis is like pexpect.spawn but allows you to supply your own open file descriptor. For example, you could use it to read through a file looking for patterns, or to control a modem or serial device. iitstrictc Cst|tdkr6t|dr6|j}nt|tdkr]tdnytj|Wntk rtdnXd|_d|_ t j |||||d|d|||_ t |_t |_d||_| |_dS( sThis takes a file descriptor (an int) or an object that support the fileno() method (returning an int). All Python file-like objects support fileno(). itfilenosdThe fd argument is not an int. If this is a command string then maybe you want to use pexpect.spawn.s/The fd argument is not a valid file descriptor.tencodingt codec_errorssN(ttypethasattrRRtostfstattOSErrortNonetargstcommandRt__init__tchild_fdtFalsetown_fdtclosedtnametuse_poll( tselftfdRttimeouttmaxreadtsearchwindowsizetlogfileRR R((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyR$s"'        cCsC|jdkrdS|jtj|jd|_t|_dS(sClose the file descriptor. Calling this method a second time does nothing, but if the file descriptor was closed elsewhere, :class:`OSError` will be raised. iN(RtflushR tclosetTrueR(R((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyR ?s   cCs:|jdkrtSytj|jtSWntSXdS(sThis checks if the file descriptor is still valid. If :func:`os.fstat` does not raise an exception then we assume it is alive. iN(RRR R R!(R((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pytisaliveMscCstddS(s1Deprecated and invalid. Just raises an exception.s.This method is not valid for file descriptors.N(R(Rtforce((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyt terminateYscCsJ|j|}|j|d|jj|dt}tj|j|S(s+Write to fd, return number of bytes writtentsendtfinal(t_coerce_send_stringt_logt_encodertencodeRR twriteR(Rtstb((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyR%`scCs#|j|}|j||jS(sAWrite to fd with trailing newline, return number of bytes written(R'R%tlinesep(RR,((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pytsendlinehscCs|j|dS(sWrite to fd, return NoneN(R%(RR,((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyR+mscCs"x|D]}|j|qWdS(s+Call self.write() for each item in sequenceN(R+(RtsequenceR,((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyt writelinesqs iicCstjdkr|dkr'|j}n|jg}g}g}|jrZt||}nt||||\}}}|j|krtdqntt |j |S(s Read from the file descriptor and return the result as a string. The read_nonblocking method of :class:`SpawnBase` assumes that a call to os.read will not block (timeout parameter is ignored). This is not the case for POSIX file-like objects such as sockets and serial ports. Use :func:`select.select`, timeout is implemented conditionally for POSIX systems. :param int size: Read at most *size* bytes. :param int timeout: Wait timeout seconds for file descriptor to be ready to read. When -1 (default), use self.timeout. When 0, poll. :return: String containing the bytes read tposixisTimeout exceeded.( R RRRRRRRtsuperRtread_nonblocking(RtsizeRtrlisttwlisttxlist((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyR4vs    N(t__name__t __module__t__doc__RRRR R"R$R%R/R+R1R4(((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyRs       ( R;t spawnbaseRt exceptionsRRtutilsRRR t__all__R(((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/fdpexpect.pyts