Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/iosim.pyc


[XMc@sdZddlZyddlmZWnek
r9nXddlmZmZddl	m
Z
ddlmZddlm
Z
ddd	YZd
ddYZdZd
ZdddYZeeedZdS(s0
Utilities and helpers for simulating a network
iN(tError(t
implementstdirectlyProvides(tFailure(terror(t
interfacestTLSNegotiationcBs#eZdZdZdZRS(cCs(||_||_t|_||_dS(N(tobjtconnectStatetFalsetsenttreadyToSend(tselfRR((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyt__init__s			cCsd|jfS(NsTLSNegotiation(%r)(R(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyt__repr__scCs2|jj|js.t|_|jndS(N(RtiosimVerifytNativeOpenSSLErrortdisconnectReasontloseConnection(Rtotherttpt((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytpretendToVerify s(t__name__t
__module__R
RR(((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyRs		t
FakeTransportcBseZdZeejejejj	Z
dZdZdZ
ejdZdZdZdZdZdZdZdZdZdZd	Zd
ZdZdZd
ZdZ dZ!dZ"dZ#e$dZ%dZ&dZ'RS(s
    A wrapper around a file-like object to make it behave as a Transport.

    This doesn't actually stream the file to the attached protocol,
    and is thus useful mainly as a utility for debugging protocols.
    isConnection donecCsg|_|j|_dS(N(tstreamt_nextserialtserial(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyR
<s	cCs,d|jrdpd|j|jjjfS(NsFakeTransport<%s,%s,%s>tStC(tisServerRtprotocolt	__class__R(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyR@scCs6|jdk	r"|jj|n|jj|dS(N(ttlstNonettlsbuftappendR(Rtdata((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytwriteEscCs|jr|jjndS(N(tproducertresumeProducing(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyt_checkProducerKs	cCs)||_||_|s%|jndS(s%From abstract.FileDescriptor
        N(R'tstreamingProducerR((RR't	streaming((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytregisterProducerQs		cCs
d|_dS(N(R"R'(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytunregisterProducerYscCs|j|jdS(N(R-R(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyt
stopConsuming\s
cCs|jdj|dS(Nt(R&tjoin(Rtiovec((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyt
writeSequence`scCs
t|_dS(N(tTruet
disconnecting(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyRcscCs>|jdk	rt}n	|j}|jjt|dS(N(R!R"RRRtconnectionLostR(Rterr((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytreportDisconnectfs	cCsdS(Ntfile(sfilesfile((R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytgetPeernscCsdS(NR8((R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytgetHostrscCsdS(N((R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyR(vscCsdS(N((R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytpauseProducingzscCs|jdS(N(R(R((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyt
stopProducing~scCs,|j|A}t|||_g|_dS(N(RRR!R#(RtcontextFactorytbeNormalR((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytstartTLSs
cCsb|j}|r%g|_dj|S|jdk	rZ|jjrSt|j_|jSdSndSdS(NR/(RR0R!R"RR3R
(RR((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytgetOutBuffers		
cCst|tr|jdk	s$t|jjr|jj||d|_|jd}|_|j|t	|t
jqt|j_
n|jj|dS(N(t
isinstanceRR!R"tAssertionErrorR
RR#R2RRt
ISSLTransportR3RRtdataReceived(Rtbuftb((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytbufferReceiveds	
N((RRt__doc__RRt
ITransportt
ITLSTransportt	itertoolstcounttnextRtclosedR4tdisconnectedRtConnectionDoneRR"R'R*R!R
RR&R)R,R-R.R2RR7R9R:R(R;R<R3R?R@RG(((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyR)s:	
																cCst}t|_||_|S(N(RR	RR(tctft((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytmakeFakeClients			cCst}t|_||_|S(N(RR3RR(tsRR((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytmakeFakeServers			tIOPumpcBs/eZdZdZedZedZRS(sUtility to pump data between clients and servers for protocol testing.

    Perhaps this is a utility worthy of being in protocol.py?
    cCs1||_||_||_||_||_dS(N(tclienttservertclientIOtserverIOtdebug(RRWRXRYRZR[((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyR
s
				cCsLt}x?tdD]}|j|r1t}qPqWdsHtd|S(sbPump until there is no more input or output.

        Returns whether any data was moved.
        iisToo long(R	trangetpumpR3RB(RR[tresulttx((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytflushs	c	Cs|js|rdGHn|jj}|jj}|jj|jj|js^|rdGH|r{dt|GHn|rdt|GHqn|r|jj|n|r|jj|n|s|rtS|jjr1|jj	r1|js|rdGHnt|j_	t|j_|jj
tS|jjr|jj	r|jsY|radGHnt|j_	t|j_|jj
tStS(sOMove data back and forth.

        Returns whether any data was moved.
        s
-- GLUG --t.sC: sS: s* Cs* S(R[RZR@RYR)treprRGR3R4ROR7R	(RR[tsDatatcData((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyR]sD




(RRRHR
R	R`R](((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyRVs	c
Css|}|}||}||}|j||j|t|||||}	|	j|||	fS(s.Returns a 3-tuple: (client, server, pump)
    (tmakeConnectionRVR`(
tServerClasstClientClasstclientTransportFactorytserverTransportFactoryR[RQRTtciotsioR]((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pytconnectedServerAndClients		


((((RHRKtOpenSSL.SSLRRtImportErrortzope.interfaceRRttwisted.python.failureRttwisted.internetRRRRRSRURVR	Rl(((s6/usr/lib/python2.7/dist-packages/twisted/test/iosim.pyt<module>s"
		G