wL iNdZddlZddlZddlZddlZddlmZmZddl m Z gdZ GddZ e jZ d ed efd Zy) z}Posix-specific implementation of process utilities. This file is only meant to be imported by process.py, not by end-users. N) getoutput arg_split)DEFAULT_ENCODING)rrsystem check_pidceZdZUdZdZeed<dZeed<dZdZ e dzed<e de dzfd Z dd Z d e de dzfd Zd e defd Zy)ProcessHandlerz7Execute subprocesses under the control of pexpect. g? read_timeoutg?terminate_timeoutN_shreturnc|j`ddl}tjj dd}|j ||_|jt dj||jS)NrSHELLshz"{}" shell not found)r pexpectosenvirongetwhichOSErrorformat)selfr shell_names b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/utils/_process_posix.pyrzProcessHandler.sh,s] 88  6J}}Z0DHxx4;;JGHHxxc.tj|_y)z%Arguments are used for pexpect calls.N)sysstdoutlogfile)rs r__init__zProcessHandler.__init__7s zz rcmdcddl}|jJ |j|jd|g}t|tsJ|j ddS#t $rtdtjd YywxYw) a"Run a command and return its stdout/stderr as a string. Parameters ---------- cmd : str A command to be executed in the system shell. Returns ------- output : str A string containing the combination of stdout and stderr from the subprocess, in whatever order the subprocess originally wrote to its file descriptors (so the order of the information in this string is the correct order as would be seen if running the command in a terminal). rN-cargsz  z^C)fileend) rrrun isinstancestrreplaceKeyboardInterruptprintrstderr)rr"rress rrzProcessHandler.getoutput;sy ww""" 1++dggT3K+8Cc3' '';;vt, ,  1 $SZZR 0 1sAA%A?>A?cddl}t}|j|jg}|j |j}d}|j J t |dr |j|j d|g}n|j|j d|g}tjj} |j||j} t|j|dj!|dd || |k(rnt#|j}i |j/|j0|j2y|j2 S|j0d kDr|j0d z S|j0S#t$$rj't)d  t#|j}|j||j*t|j|dj!|dd tjjn#t$$rYnwxYw|j-d n#|j-d wxYwY;wxYw) zExecute a command in a subshell. Parameters ---------- cmd : str A command to be executed in the system shell. Returns ------- int : child's exitstatus rNspawnbr$r%Tr.r()r*)force)rrTIMEOUTEOFindexrhasattrr4spawnrrflush expect_listr r0beforedecodelenr/sendlinechrr terminateisalive exitstatus signalstatus) rr"rencpatterns EOF_indexout_sizechildr=res_idxs rrzProcessHandler.systemVs" OOW[[1NN7;;/ ww"""& , w)twwdC[A dggT3K @JJ$$E ++Hd6G6GHell89-44S)D"MI%u||,,      #!!)&&& &   c !%%+, ,G! , NN3q6 " ,u||,!!(D,B,BCell89-44S)D"M   "$   d+d++# ,sJCF#I$A9HI H*'I)H**I-IIII)rN)__name__ __module__ __qualname____doc__r float__annotations__r r r r-propertyrr!rintrrrr r s L% #u"GCt C$J"SS4Z6V #V #V rr pidrc tj|dy#t$rJ}|jtjk(rYd}~y|jtj k(rYd}~yd}~wwxYw)NrTF)rkillrerrnoESRCHEPERM)rWerrs rrrsT  Q  99 # YY%++ % s  A,A'A'&A''A,)rQrZr subprocessspr_process_commonrrIPython.utils.encodingr__all__r rrUboolrrVrrrdsU  ?3 ; R R t    3 4 r