Repository URL to install this package:
|
Version:
0.1.31 ▾
|
odigos-demo-inventory
/
opt
/
odigos-demo-inventory
/
site-packages
/
pexpect
/
__pycache__
/
fdpexpect.cpython-311.pyc
|
|---|
§
hµµhg ã ó` d Z ddlmZ ddlmZmZ ddlmZmZ ddl Z dgZ
G d de¦ « ZdS ) a This is like :mod:`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).
.. note::
socket.fileno() does not give a readable file descriptor on windows.
Use :mod:`pexpect.socket_pexpect` for cross-platform socket support
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 <noah@noah.org>
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.
é )Ú SpawnBase)ÚExceptionPexpectÚTIMEOUT)Úselect_ignore_interruptsÚpoll_ignore_interruptsé NÚfdspawnc ó\ e Zd ZdZ ddZd Zd Zdd
Zd Zd Z d
Z
d Zd fd Z xZ
S )r zÎThis 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. Né éÐ ÚstrictFc
óð t |¦ « t d¦ « k r$t |d¦ « r| ¦ « }t |¦ « t d¦ « k rt d¦ « t j |¦ « n# t $ r t d¦ « w xY wd| _ d| _ t j
| ||||||¬¦ « || _ d| _ d| _
d|z | _ | | _ dS ) z§This takes a file descriptor (an int) or an object that support the
fileno() method (returning an int). All Python file-like objects
support fileno(). r ÚfilenozdThe fd argument is not an int. If this is a command string then maybe you want to use pexpect.spawn.z/The fd argument is not a valid file descriptor.N)ÚencodingÚcodec_errorsFz<file descriptor %d>)ÚtypeÚhasattrr r ÚosÚfstatÚOSErrorÚargsÚcommandr Ú__init__Úchild_fdÚown_fdÚclosedÚnameÚuse_poll)
ÚselfÚfdr ÚtimeoutÚmaxreadÚsearchwindowsizeÚlogfiler r r s
ú</usr/local/lib/python3.11/site-packages/pexpect/fdpexpect.pyr zfdspawn.__init__( s õ 88tAwwÒÐ¥7¨2¨xÑ#8Ô#8ÐØBå88tAwwÒÐÝ"ð $Jñ Kô Kð
Kð VÝHRLLLLøÝð Vð Vð VÝ"Ð#TÑUÔUÐUð Vøøøð ØÝÔ4 ¨'Ð3CÀWØ$,¸<ð Iñ Iô Ið Ià
ØØØ*¨RÑ/ Ø
s Á5B
Â
B$c ó | j dk rdS | ¦ « t j | j ¦ « d| _ d| _ dS )z¶Close the file descriptor.
Calling this method a second time does nothing, but if the file
descriptor was closed elsewhere, :class:`OSError` will be raised.
éÿÿÿÿNT)r Úflushr Úcloser ©r s r% r) z
fdspawn.closeC sG ð =BÒÐØFà
Ý
ÑÔÐØ
Øó c ód | j dk rdS t j | j ¦ « dS # Y dS xY w)zThis checks if the file descriptor is still valid. If :func:`os.fstat`
does not raise an exception then we assume it is alive. r' FT)r r r r* s r% Úisalivezfdspawn.isaliveQ sB ð =BÒÐØ5ð ÝHT]Ñ#Ô#Ð#Ø4øð Ø55øøøs * ª/c ó t d¦ « )z1Deprecated and invalid. Just raises an exception.z.This method is not valid for file descriptors.)r )r Úforces r% Ú terminatezfdspawn.terminate] s åÐOÑPÔPÐPr+ c óÄ | |¦ « }| |d¦ « | j |d¬¦ « }t j | j |¦ « S )z+Write to fd, return number of bytes writtenÚsendF)Úfinal)Ú_coerce_send_stringÚ_logÚ_encoderÚencoder Úwriter )r ÚsÚbs r% r2 zfdspawn.sendd sW à×$Ò$ QÑ'Ô'Ø !VÑÔÐàM× Ò ¨%Ð Ñ0Ô0Ýx
qÑ)Ô)Ð)r+ c óf | |¦ « }| || j z ¦ « S )zAWrite to fd with trailing newline, return number of bytes written)r4 r2 Úlinesep©r r9 s r% Úsendlinezfdspawn.sendlinel s. à×$Ò$ QÑ'Ô'ØyyT\Ñ)Ñ*Ô*Ð*r+ c ó0 | |¦ « dS )zWrite to fd, return NoneN)r2 r= s r% r8 z
fdspawn.writeq s à !r+ c ó: |D ]}| |¦ « dS )z+Call self.write() for each item in sequenceN)r8 )r Úsequencer9 s r% Ú
writelineszfdspawn.writelinesu s, àð ð AØJJqMMMMð ð r+ r r' c ó2 t j dk r_|dk r| j }| j g}g }g }| j rt ||¦ « }nt
||||¦ « \ }}}| j |vrt d¦ « t t | ¦ «
|¦ « S )a¢
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
Úposixr' zTimeout exceeded.)r r r! r r r r r Úsuperr Úread_nonblocking)r Úsizer! ÚrlistÚwlistÚxlistÚ __class__s r% rF zfdspawn.read_nonblockingz s« ø õ 7gÒÐØ"}}Ø,Ø]OEØEØEØ}ð
Ý.¨u°gÑ>Ô>å&>Ø5 %¨ñ'ô 'Ñ#ueð } EÐ)Ð)ÝÐ1Ñ2Ô2Ð2ÝWdÑ#Ô#×4Ò4°TÑ:Ô:Ð:r+ )Nr r NNNr
F)F)r r' )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r r) r- r0 r2 r>