HEX
Server: Apache
System: Linux eisbus 6.8.12-9-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-9 (2025-03-16T19:18Z) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //proc/400/root/lib/python2.7/dist-packages/command.pyc
�
#�dc@s(dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlTddl
mZddlmZd�Zd�Zd	�Zd
fd��YZdefd
��YZdfd��YZeaeaed�Zd�ZdS(s,A high-level interface for command executioni����N(t
FIFOBuffer(t*(tmkarg(tStringIOcCsy|s
dS|d}xMt|�D]?\}}tjd|�rRt|�||<q!d|||<q!W|ddj|�S(Ntis[\s'\"]t i(t	enumeratetretsearchRtjoin(targvtargstitarg((s+/usr/lib/python2.7/dist-packages/command.pytfmt_argvs
cCs=ddl}|j||jd�}|tj@r5tStSdS(Ni����i(tfcntltF_GETFLtost
O_NONBLOCKtFalsetTrue(tfdRtflags((s+/usr/lib/python2.7/dist-packages/command.pytget_blocking*s

cCs�ddl}|j||jd�}|dkr9d}n|s_|j||j|tjB�n|j||j|tj@�dS(Ni����i(RRtF_SETFLRR(RtblockingRR((s+/usr/lib/python2.7/dist-packages/command.pytset_blocking2s	 tFileEnhancedReadcBs)eZd�Zd�Zddd�ZRS(cCs
||_dS(N(tfh(tselfR((s+/usr/lib/python2.7/dist-packages/command.pyt__init__>scCst|j|�S(N(tgetattrR(Rtattr((s+/usr/lib/python2.7/dist-packages/command.pyt__getattr__Asi����cCsw|dkr|jj|�S|dkr1d}n|jj�}d}tj�}|j|tjtjB�t	j	�}y|j|d�}Wn/tj
k
r�|j||t	j	�|�SX|s�dS|dd}|tj@rbd}	t|�}
t|t
�zHy|jj|�}	Wn+tk
rK}|jtjkrL�qLnXWdt||
�X|	S|tj@rsdSdS(sA better read where you can (optionally) configure how long to wait for data.

        Arguments:
            
        'timeout': how many seconds to wait before for output.

                If no output return None.
                If EOF return ''

        ii�iNR(tNoneRtreadtfilenotselecttpolltregistertPOLLINtPOLLHUPttimeterrorRRRtIOErrorterrnotEAGAIN(RtsizettimeoutRtoutputtptstartedteventstmasktbytest
orig_blockingte((s+/usr/lib/python2.7/dist-packages/command.pyR#Ds<	


N(t__name__t
__module__RR!R"R#(((s+/usr/lib/python2.7/dist-packages/command.pyR=s		tCommandcBseZdZdefd��YZdefd��YZdeded�Z	d�Z
d�Zdej
d	�Zd
�Zee�Zd�Zee�Zd�Zee�Zdd
dd�Zd�Zee�Zd�Zee�Zded�Zddd�Zd�Zd�ZRS(s�Convenience module for executing a command

    attribute notes::

        'exitcode' - None if the process hasn't exited, exitcode otherwise

        'output' - None if the process hasn't exited and fromchild hasn't
                   been accessed, the full output of the process

        'running' - True if process is still running, False otherwise

        'terminated' - Returns signal number if terminated, None otherwise

    Usage example::

        c = Command("./test.py")
        if c.running:
            c.wait()

        assert c.running is False

        print c.output

        c = Command("./test.py")

        # Unless you read from command.fromchild or use
        # command.outputsearch() command.output will be None until the
        # command finishes.

        while c.output is None: 
            time.sleep(1)

        print "output = '%s', exitcode = %d" % (c.output, c.exitcode)

        c = Command("cat", pty=True)
        print >> c.tochild, "test"
        print c.fromchild.readline(),

    tErrorcBseZRS((R9R:(((s+/usr/lib/python2.7/dist-packages/command.pyR<�st_ChildObservercBs&eZed�Zd�Zd�ZRS(cCs||_||_dS(N(tdebugt	outputbuf(RR?R>((s+/usr/lib/python2.7/dist-packages/command.pyR�s	cCs'|jr#tjd||fIJndS(Ns# EVENT '%s':
%s(R>tsyststderr(Rteventtmsg((s+/usr/lib/python2.7/dist-packages/command.pyt_dprint�s	cCst|dkr/|j||�|jj|�nA|dkrp|j|dj|��|jjdj|��ndS(NR#treadlinet	readlinest
xreadlinesR(R#RE(RFRG(RDR?twriteR	(RtsubjectRBtval((s+/usr/lib/python2.7/dist-packages/command.pytnotify�s(R9R:RRRDRK(((s+/usr/lib/python2.7/dist-packages/command.pyR=�s	cCs�tj�|_d|_tj|d|||�|_|jj|_d|_|jj	|_	||_
||_||_t
�|_|jd|jj	|
|f�dS(sSArgs:
        'cmd' what command to execute
            Can be a list ("/bin/ls", "-la")
            or a string "/bin/ls" (will be passed to sh -c)

        'pty' do we allocate a pty for command?
        'runas' user we run as (set user, set groups, etc.)
        'setpgrp' do we setpgrp in child? (create its own process group)
        is&# command started (pid=%d, pty=%s): %sN(RtgetpidtppidR"t_childtpopen4tPopen4ttochildt
_fromchildtpidt_setpgrpt_debugt_cmdRt_outputRD(RtcmdtrunastptytsetpgrpR>((s+/usr/lib/python2.7/dist-packages/command.pyR�s					cCs3|js
dStj�|jkr/|j�ndS(N(RNRRLRMt	terminate(R((s+/usr/lib/python2.7/dist-packages/command.pyt__del__�s	cCs|jrtj|IJndS(N(RUR@RA(RRC((s+/usr/lib/python2.7/dist-packages/command.pyRD�s	icCsu|jrq|jjrWtj|jjj��d}|tj}|jjj|�n|j	}|j
rs|}nytj||�WnSt
k
r�}|dtjks�|jjs�|jdddd�r��ndSXx.t|�D] }|js�dStjd�q�W|jrqtj|tj�|jdd	dd�sT|jd
��n|jd|jj	�qqndS(siterminate command. kills command with 'sig', then sleeps for 'gracetime', before sending SIGKILL
        i����iR0it
poll_intervalg�������?Niisprocess just won't die!s# command (pid %d) terminated(trunningRNRZttermiost	tcgetattrRQR$tVINTRRHRSRTRtkilltOSErrorR-tEPERMtwaittrangeR*tsleeptsignaltSIGKILLR<RD(Rt	gracetimetsigtcc_magictctrl_cRSR8R((s+/usr/lib/python2.7/dist-packages/command.pyR\�s2	
		

		cCs/|jj�}tj|�s"dStj|�S(N(RNR&RtWIFSIGNALEDR"tWTERMSIG(Rtstatus((s+/usr/lib/python2.7/dist-packages/command.pyt
terminatedscCs|jj�dkrtStS(Ni����(RNR&RR(R((s+/usr/lib/python2.7/dist-packages/command.pyR_scCs<|jr
dS|jj�}tj|�s/dStj|�S(N(R_R"RNR&Rt	WIFEXITEDtWEXITSTATUS(RRq((s+/usr/lib/python2.7/dist-packages/command.pytexitcodes	g�������?cCs�|js
tS|dkr*|jj�tStj�}xMtj�||kr�|rh|�tkrhtS|jsutStj|�q9WtSdS(s{wait for process to finish executing.
        'timeout' is how long we wait in seconds (None is forever)
        'poll_interval' is how long we sleep between checks to see if process has finished
        'callback': you can use callback to check for other conditions (e.g., besides timeout) and stop wait early.

        return value: did the process finish? True/False

        N(R_RR"RNRfR*RRh(RR0R^tcallbacktstart((s+/usr/lib/python2.7/dist-packages/command.pyRfs		
	cCsCt|j�r|jj�S|jr)dS|jj�|jj�S(N(tlenRWtgetvalueR_R"t	fromchildR#(R((s+/usr/lib/python2.7/dist-packages/command.pyR19s
	
cCs]|jr|jSt|jj�}|j|j|j|j��t|�}||_|jS(sareturn the command's filehandler.

        NOTE: this file handler magically updates self._output(	RRtFileEventAdaptorRNRztaddObserverR=RWRUR(RR((s+/usr/lib/python2.7/dist-packages/command.pyRzGs	
	c	s(g�t|�ttfkr.�j|�n
�|7�ttjd��}xltt���D]X}t�|�|k	r�tj�|��|f�|<q`�|�|f�|<q`W���fd����}|r�|Sdg�tj������fd�}�j	|�}�dS(s0Search for 'p' in the command's output, while listening for more output from command, within 'timeout'

        'p' can be a list of re patterns or a single re pattern
           the value of a pattern can be an re string, or a compiled re object
        If 'timeout' is None, wait forever [*]

	'linemode' determines whether we search output line by line (as it comes), or all of the output in aggregate
        
        Return value:
        Did we match the output?
            Return a tuple (the pattern we matched, the string match)
        Otherwise (timeout/HUP) Return empty tuple ()

        Side effects:
        - If we HUP, we wait for the process to finish.
          You can check if the process is still running.

        - Output is collected and can be accessed by the output attribute [*]
        Rcs��rux��jjt�}|s%dSx3�D]+\}}|j|�}|r,||fSq,W|jd�s	dSq	Wn?x<�D]4\}}|j�jj��}|r|||fSq|WdS(Ns
(RWRERR"RtendswithRy(tlinet
pattern_retpattern_origtmatch(tlinemodetpatternsR(s+/usr/lib/python2.7/dist-packages/command.pytcheck_match~scsi|r&��}|r&|�d<tSn|dkr6tS�dk	retj��}|�kretSntS(NiR(RR"R*R(Rtbuftmtelapsed_time(R�trefR3R0(s+/usr/lib/python2.7/dist-packages/command.pyRv�s	
i((
ttypettupletlisttappendRtcompiletxrangeRxR*R#(	RR2R0R�tre_typeRR�RvR((R�R�R�R�RR3R0s+/usr/lib/python2.7/dist-packages/command.pytoutputsearchZs$
$		g�������?cCs�|s|jj�St�}x�tr�|jjd|�}|rP|j|�n|||�tk}|ru|j�S|js�Pn|dkr|j�PqqW|dkr�|jj�}|j|�|||�n|j�S(s�Read output from child.

        Args:
        'callback': callback(command, readbuf) every read loop or 
                    callback_interval (whichever comes sooner).

                    readbuf may be:
                     
                    1) a string
                    2) None (no input during callback_interval)
                    2) an empty string (EOF)

                    If callbacks returns False, stop reading

        Return read bytes.

        R0R(	RzR#RRRHRRyR_Rf(RRvtcallback_intervaltsioR1tfinishedt	leftovers((s+/usr/lib/python2.7/dist-packages/command.pyR#�s(
		
	

cCsd|j
S(NsCommand(%s)(RV(R((s+/usr/lib/python2.7/dist-packages/command.pyt__repr__�scCs&t|jt�r|jSt|j�S(N(t
isinstanceRVtstrR(R((s+/usr/lib/python2.7/dist-packages/command.pyt__str__�sN(R9R:t__doc__t	ExceptionR<tObserverR=R"RRR]RDRitSIGTERMR\RrtpropertyR_RuRfR1RzR�R#R�R�(((s+/usr/lib/python2.7/dist-packages/command.pyR;xs,'		%			
		V/	tCommandTruecBs5eZdZd�Zdd�Zd�Zd�ZRS(sa
    Simplified interface to Command class.
    
    A command istrue() if its exitcode == 0
    cCst|�|_dS(N(R;t_c(RRX((s+/usr/lib/python2.7/dist-packages/command.pyR�scCs|jj|�S(N(R�Rf(RR0((s+/usr/lib/python2.7/dist-packages/command.pyRf�scCs|jj�dS(N(R�R\(R((s+/usr/lib/python2.7/dist-packages/command.pyR\�scCs.|jj}|dkrdS|r&tStSdS(N(R�RuR"RR(RRu((s+/usr/lib/python2.7/dist-packages/command.pytistrue�sN(R9R:R�RR"RfR\R�(((s+/usr/lib/python2.7/dist-packages/command.pyR��s
		cCs8t|d|�}|j�|ja|jatdkS(s�convenience function
    execute 'cmd' and return True/False is exitcode == 0

    Side effect: sets command.last_exitcode and command.last_output
    R[i(R;RfR1tlast_outputRut
last_exitcode(RXR[tc((s+/usr/lib/python2.7/dist-packages/command.pytevals
	
		cCs,t|�}|j�|ja|jatS(s�convenience function
    execute 'cmd' and return it's output

    Side effect: sets command.last_exitcode and command.last_output

    (R;RfR1R�RuR�(RXR�((s+/usr/lib/python2.7/dist-packages/command.pyR1s


		(R�RRiR*R%RR@R-R`ROt
fifobufferRt	fileeventtcommandsRRRRRRtobjectR;R�R"R�R�RR�R1(((s+/usr/lib/python2.7/dist-packages/command.pyt<module>
s0
			;�q