Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/lib/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyc

ó
ÍÿŠTc
@s¢ddlmZmZddlmZddlmZmZddlm	Z	ddl
Z
ed„Zdefd„ƒYZ
d
idddeeddd	„	ZdS(iÿÿÿÿ(tDeferredListtDeferred(tProcessProtocol(tProcesst
ProcessReader(treactorNcCs<t|ddd|ƒ}|jd„ƒ|jd„ƒ|S(NtfireOnOneErrbackit
consumeErrorscSsg|D]}|d^qS(Ni((trtx((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyt<lambda>scSs
|jjS(N(tvaluet
subFailure(tf((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyR

s(RtaddCallbackt
addErrback(t	deferredstconsume_errorstd((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pytgather_results	s
	tAllOutputProcessProtocolcBs8eZdZddd„Zd„Zd„Zd„ZRS(s<A process protocol for getting stdout, stderr and exit code.cCsU||_tjƒ|_tjƒ|_|jj|_||_||_d|_	dS(Nt(
tdeferredt	cStringIOtStringIOtoutBufterrBuftwriteterrReceivedtstdint
line_receivedt
_partial_line(tselfRRR((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyt__init__s			cCs6|jdk	r2|jj|jƒ|jjƒndS(N(RtNonet	transportRt
closeStdin(R ((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pytconnectionMadescCsx|jj|ƒ|jdkr#dS|jdƒ}|j|d|d<|jƒ|_x|D]}|j|ƒq]WdS(Ns
i(RRRR"tsplitRtpop(R tdatatlinestline((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pytoutReceived"s
cCsš|jr%|j|jƒd|_n|jjƒ}|jjƒ}|j}|j}|jr}|jj	|||jfƒn|jj
|||fƒdS(NR(RRRtgetvalueRRtexitCodetsignalRterrbacktcallback(R treasontoutterrtetcode((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pytprocessEnded2s				N(t__name__t
__module__t__doc__R"R!R%R+R6(((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyRs
			c
s’|g}
|
j|ƒtƒ}t|d|	d|ƒ}tj||d|
d|d|d|d|d|ƒ‰|sއfd	†}
|
ˆ_n|S(
sï
    Spawn a process using Twisted reactor.

    Return a deferred which will be called with process stdout, stderr and exit
    code.

    @param wait_pipes: if set to False, don't wait for stdin/stdout pipes to
        close when process ends.
    @param line_received: an optional callback called with every line of
        output from the process as parameter.

    @note: compared to reactor.spawnProcess, this version does NOT require the
    executable name as first element of args.
    RRtargstenvtpathtuidtgidtusePTYcspˆjr_ˆjr_x=ˆjjƒD],}t|tƒrE|jƒn|jƒq#Wiˆ_ntjˆƒdS(sëA less strict version of Process.maybeCallProcessEnded.

            This behaves exactly like the original method, but in case the
            process has ended already and sent us a SIGCHLD, it doesn't wait
            for the stdin/stdout pipes to close, because the child process
            itself might have passed them to its own child processes.

            @note: Twisted 8.2 now has a processExited hook that could
                be used in place of this workaround.
            N(	tpipestpidt
itervaluest
isinstanceRtdoReadtstopReadingRtmaybeCallProcessEnded(tpipe(tprocess(s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyRF^s
(textendRRRtspawnProcessRF(t
executableR:R;R<R=R>R?t
wait_pipesRRt	list_argstresulttprotocolRF((RHs>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyt
spawn_process@s	
			((ttwisted.internet.deferRRttwisted.internet.protocolRttwisted.internet.processRRttwisted.internetRRtFalseRRR"tTrueRP(((s>/usr/lib/python2.7/dist-packages/landscape/lib/twisted_util.pyt<module>s/