403Webshell
Server IP : 61.19.30.66  /  Your IP : 216.73.216.15
Web Server : Apache/2.2.22 (Ubuntu)
System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64
User : www-data ( 33)
PHP Version : 5.3.10-1ubuntu3.48
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python2.7/dist-packages/twisted/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyc
ó
ê=Nc@sdZddlZddlZddlZddlmZddlmZmZddl	m
Z
ddlmZm
Z
mZmZmZddlmZdZdZe
jƒrÝyddlZWqÝek
rÙd	ZqÝXnd
ejfd„ƒYZdejfd
„ƒYZdS(s&
Tests for L{twisted.internet.stdio}.
iÿÿÿÿN(tunittest(tfilepathtlog(tplatform(terrortdefertprotocoltstdiotreactor(tConnectionLostNotifyingProtocolsxyz123abc Twisted is great!sIOn windows, spawnProcess is not available in the absence of win32process.tStandardIOTestProcessProtocolcBs8eZdZdZd„Zd„Zd„Zd„ZRS(sÕ
    Test helper for collecting output from a child process and notifying
    something when it exits.

    @ivar onConnection: A L{defer.Deferred} which will be called back with
    C{None} when the connection to the child process is established.

    @ivar onCompletion: A L{defer.Deferred} which will be errbacked with the
    failure associated with the child process exiting when it exits.

    @ivar onDataReceived: A L{defer.Deferred} which will be called back with
    this instance whenever C{childDataReceived} is called, or C{None} to
    suppress these callbacks.

    @ivar data: A C{dict} mapping file descriptors to strings containing all
    bytes received from the child process on each file descriptor.
    cCs+tjƒ|_tjƒ|_i|_dS(N(RtDeferredtonConnectiontonCompletiontdata(tself((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt__init__5scCs|jjdƒdS(N(RtcallbacktNone(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pytconnectionMade;scCsV|jj|dƒ||j|<|jdk	rR|jd}|_|j|ƒndS(s“
        Record all bytes received from the child process in the C{data}
        dictionary.  Fire C{onDataReceived} if it is not C{None}.
        tN(RtgettonDataReceivedRR(Rtnametbytestd((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pytchildDataReceived?s cCs|jj|ƒdS(N(R
R(Rtreason((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pytprocessEndedJsN(	t__name__t
__module__t__doc__RRRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyR
!s			tStandardInputOutputTestCasecBs×eZeZd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd„Zd	„Z
d
„Zd„Zejjdkr–d
e_nejƒr®de_nd„ZejjdkrÕde_nRS(cOsÀddl}ttjƒ}tjjtjjtjjtjj|j	ƒƒƒ|j
ddƒgƒ|d<tjt
jt	ƒj|ƒjtjjgt|ƒ}tj|tj|d||S(s_
        Launch a child Python process and communicate with it using the
        given ProcessProtocol.

        @param proto: A L{ProcessProtocol} instance which will be connected
        to the child process.

        @param sibling: The basename of a file containing the Python program
        to run in the child process.

        @param *args: strings which will be passed to the child process on
        the command line as C{argv[2:]}.

        @param **kw: additional arguments to pass to L{reactor.spawnProcess}.

        @return: The L{IProcessTransport} provider for the spawned process.
        iÿÿÿÿNt
PYTHONPATHRtenv(ttwistedtdicttostenvirontpathseptjointpathtabspathtdirnamet__file__Rtsyst
executableRtFilePathtsiblingRt	__class__RtlisttspawnProcess(RtprotoR0targstkwR#tsubenv((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt
_spawnProcessSs		!cs.‡fd†}‡fd†}|j||ƒS(Ncsˆjd|fƒdS(Ns'Process terminated with non-Failure: %r(tfail(tresult(R(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pytcbxscs
ˆ|ƒS(N((terr(R(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pytebzs(taddCallbacks(RRRR;R=((RRs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt_requireFailurewscsgˆjƒ‰tjdˆƒtƒ‰ˆj}ˆjˆdˆƒ‡‡‡fd†}ˆj||ƒS(s„
        Verify that a protocol connected to L{StandardIO} can disconnect
        itself using C{transport.loseConnection}.
        sChild process logging to sstdio_test_loseconn.pycsUx+tˆƒD]}tjd|jƒƒq
Wˆjdˆjƒ|jtjƒdS(NsChild logged: i(	tfileRtmsgtrstriptfailIfInRttrapRtProcessDone(Rtline(RtpterrorLogFile(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyRŠs(tmktempRRAR
R
R8R?(RRR((RRGRHs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyttest_loseConnections		cs‰|jƒ}tjd|ƒtƒ‰tjƒˆ_‡fd†}ˆjj|ƒd„}|jˆj|ƒ}|j	ˆd|ƒ|S(s´
        When stdin is closed and the protocol connected to it implements
        L{IHalfCloseableProtocol}, the protocol's C{readConnectionLost} method
        is called.
        sChild process logging to csˆj}ˆjjƒ|S(N(R
t	transportt
closeStdin(tignoredR(RG(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pytcbBytesŸs	
cSs|jtjƒdS(N(RDRRE(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyR¥ssstdio_test_halfclose.py(
RIRRAR
RRRtaddCallbackR?R8(RRHRNRR((RGs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyttest_readConnectionLost”s		
csvtƒ‰yˆjˆdtdtƒWn(tk
rP}tjt|ƒƒ‚nX‡‡fd†}ˆjˆj	|ƒS(s¶
        Verify that a write made directly to stdout using L{os.write}
        after StandardIO has finished is reliably received by the
        process reading that stdout.
        sstdio_test_lastwrite.pytusePTYcs>ˆjˆjdjtƒdˆjfƒ|jtjƒdS(s‰
            Asserts that the parent received the bytes written by the child
            immediately after the child starts.
            is4Received %r from child, did not find expected bytes.N(t
assertTrueRtendswithtUNIQUE_LAST_WRITE_STRINGRDRRE(R(RGR(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyRÈs
(
R
R8RTtTruet
ValueErrorRtSkipTesttstrR?R
(RteR((RRGs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyttest_lastWriteReceived®s	
csDtƒ‰ˆj}ˆjˆdƒ‡‡fd†}ˆj||ƒS(sƒ
        Verify that the transport of a protocol connected to L{StandardIO}
        has C{getHost} and C{getPeer} methods.
        sstdio_test_hostpeer.pycsGˆjdjƒ\}}ˆj|ƒˆj|ƒ|jtjƒdS(Ni(Rt
splitlinest
failUnlessRDRRE(Rthosttpeer(RRG(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyRÞs

(R
R
R8R?(RRR((RGRs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyttest_hostAndPeerÕs
		csDtƒ‰ˆj}ˆjˆdƒ‡‡fd†}ˆj||ƒS(s
        Verify that the C{write} method of the transport of a protocol
        connected to L{StandardIO} sends bytes to standard out.
        sstdio_test_write.pycs+ˆjˆjddƒ|jtjƒdS(Nisok!(tassertEqualRRDRRE(R(RGR(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyRðs(R
R
R8R?(RRR((RGRs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt
test_writeæs
		csDtƒ‰ˆj}ˆjˆdƒ‡‡fd†}ˆj||ƒS(s˜
        Verify that the C{writeSequence} method of the transport of a
        protocol connected to L{StandardIO} sends bytes to standard out.
        sstdio_test_writeseq.pycs+ˆjˆjddƒ|jtjƒdS(Nisok!(R`RRDRRE(R(RGR(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyRs(R
R
R8R?(RRR((RGRs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyttest_writeSequenceös
		cCsW|jƒ}t|dƒ}x+tdƒD]}|jt|ƒdƒq(W|jƒ|S(Ntwis
(RIR@txrangetwriteRXtclose(RtjunkPathtjunkFileti((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt	_junkPaths
cs†tƒ‰ˆj}g‰tdƒ‰‡‡‡‡fd†‰ˆjˆdƒ‰ˆjjˆƒ‡‡‡‡fd†}ˆj||ƒS(s€
        Verify that the transport of a protocol connected to L{StandardIO}
        is a working L{IProducer} provider.
        idcsNˆrJˆjtˆjƒƒdƒˆjˆdƒtjdˆdƒndS(Ns
iÿÿÿÿg{®Gáz„?(tappendRXtpopReRt	callLaterR(tign(RttoWritetwrittentproc(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyRssstdio_test_producer.pycsQˆjˆjddjˆƒƒˆjˆdtˆƒfƒ|jtjƒdS(NiRs*Connection lost with %d writes left to go.(R`RR(tfailIftlenRDRRE(R(RoRRpRG(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyR$s (R
R
trangeR8RROR?(RRR((RRoRRGRpRqs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt
test_producers		csVtƒ‰ˆj}ˆjƒ‰ˆjˆdˆƒ‡‡‡fd†}ˆj||ƒS(s€
        Verify that the transport of a protocol connected to L{StandardIO}
        is a working L{IConsumer} provider.
        sstdio_test_consumer.pycs7ˆjˆjdtˆƒjƒƒ|jtjƒdS(Ni(R`RR@treadRDRRE(R(RgRRG(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyR7s#(R
R
RjR8R?(RRR((RgRRGs;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt
test_consumer+s		cs.tjƒ}t|ƒ}tjˆjƒƒ‰ˆjdƒˆ_}ˆj|j	ƒt
d|jƒƒ}tj
ƒs¹tjƒ\}}ˆjtj	|ƒˆjtj	|ƒ||d<ntj||‰d‰tjƒ‰‡‡‡‡fd†‰tjdˆƒ‡‡‡‡fd†}|j|ƒ|S(sE
        If L{StandardIO} is created with a file descriptor which refers to a
        normal file (ie, a file from the filesystem), L{StandardIO.write}
        writes bytes to that file.  In particular, it does not immediately
        consider the file closed or call its protocol's C{connectionLost}
        method.
        RctstdouttstdinicsSx<ˆD]4}|ˆkr'ˆjƒdSˆjt|ƒƒPqWtjdˆƒdS(Ni(tloseConnectionReRXRRm(tvalue(tcountthowManyt
connectiontspin(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyR\s

icsLˆjˆjƒˆdƒˆjˆjƒdjtttˆƒƒƒƒdS(NiR(R`tnextt
getContentR(tmapRXRt(R(R|R}RR)(s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pytcbLosths	(RRR	RR/RItopentnormalt
addCleanupRfR$tfilenoRt	isWindowsR%tpipeRt
StandardIOt	itertoolsR|RRmRO(Rt
onConnLostR4R…tkwargstrRcRƒ((R}RR)RR|R~s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyttest_normalFileStandardOut=s&

tEPollReactorsrepoll(7) does not support normal files.  See #4429.  This should be a todo but technical limitations prevent this.spStandardIO does not accept stdout as an argument to Windows.  Testing redirection to a file is therefore harder.cCs”tj|jƒƒ}|jdƒ}|jƒ}|j|jƒ|jtt	j
tjƒd|ƒ}|j
t|ƒd|tj|ƒjfƒdS(sÚ
        Using StandardIO with epollreactor with stdout redirected to a
        normal file fails with a comprehensible error (until it is
        supported, when #4429 is resolved).  See also #2259 and #3442.
        RcRxs’This reactor does not support this type of file descriptor (fd %d, mode %d) (for example, epollreactor does not support normal files.  See #4429).N(RR/RIR„R‡R†RftassertRaisestRuntimeErrorRRŠRtProtocolR`RXR%tfstattst_mode(RR)R…tfdtexc((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt(test_normalFileStandardOutGoodEpollErrorzs	sNOnly epollreactor is expected to fail with stdout redirected to a normal file.(RRtskipWindowsNopywin32tskipR8R?RJRPRZR_RaRbRjRuRwRRR1RRˆR˜(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyR Os(	$				'								2	(RR%R-R‹t
twisted.trialRttwisted.pythonRRttwisted.python.runtimeRttwisted.internetRRRRRttwisted.test.test_tcpR	RTRR™Rˆtwin32processtImportErrortProcessProtocolR
tTestCaseR (((s;/usr/lib/python2.7/dist-packages/twisted/test/test_stdio.pyt<module>s$(

.

Youez - 2016 - github.com/yon3zu
LinuXploit