>,Rc@`s,dZddlmZmZddlZddlmZmZmZddl m Z ddl Z ddl m Z ddlmZddlmZmZmZmZdd lmZerd Zn d Zd e_dZd efdYZdefdYZdejfdYZdejfdYZdfdYZ deje fdYZ!de"fdYZ#de$fdYZ%deje fdYZ&de&fd YZ'd!e&fd"YZ(d#e&fd$YZ)d%fd&YZ*e ej+d'fd(YZ,dS()sN Basic protocols, such as line-oriented, netstring, and int prefixed strings. i(tabsolute_importtdivisionN(tpacktunpacktcalcsize(tBytesIO(t implementer(t_PY3(tprotocoltdefert interfacesterror(tlogcC`s.djtt|jdd|dgS(Nttasciit:t,(tjointstrtlentencode(tdata((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyt_formatNetstringscC`sdt||fS(Ns%d:%s,(R(R((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR ss_ Convert some C{bytes} into netstring format. @param data: C{bytes} that will be reformatted. tNetstringParseErrorcB`seZdZRS(s= The incoming data is not in valid Netstring format. (t__name__t __module__t__doc__(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR,stIncompleteNetstringcB`seZdZRS(s2 Not enough data to complete a netstring. (RRR(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR3stNetstringReceivercB`seZdZdZejdZejdZdZdZ dZ dZ e d\Z Zd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZ RS(sM A protocol that sends and receives netstrings. See U{http://cr.yp.to/proto/netstrings.txt} for the specification of netstrings. Every netstring starts with digits that specify the length of the data. This length specification is separated from the data by a colon. The data is terminated with a comma. Override L{stringReceived} to handle received netstrings. This method is called with the netstring payload as a single argument whenever a complete netstring is received. Security features: 1. Messages are limited in size, useful if you don't want someone sending you a 500MB netstring (change C{self.MAX_LENGTH} to the maximum length you wish to accept). 2. The connection is lost if an illegal message is received. @ivar MAX_LENGTH: Defines the maximum length of netstrings that can be received. @type MAX_LENGTH: C{int} @ivar _LENGTH: A pattern describing all strings that contain a netstring length specification. Examples for length specifications are C{b'0:'}, C{b'12:'}, and C{b'179:'}. C{b'007:'} is not a valid length specification, since leading zeros are not allowed. @type _LENGTH: C{re.Match} @ivar _LENGTH_PREFIX: A pattern describing all strings that contain the first part of a netstring length specification (without the trailing comma). Examples are '0', '12', and '179'. '007' does not start a netstring length specification, since leading zeros are not allowed. @type _LENGTH_PREFIX: C{re.Match} @ivar _PARSING_LENGTH: Indicates that the C{NetstringReceiver} is in the state of parsing the length portion of a netstring. @type _PARSING_LENGTH: C{int} @ivar _PARSING_PAYLOAD: Indicates that the C{NetstringReceiver} is in the state of parsing the payload portion (data and trailing comma) of a netstring. @type _PARSING_PAYLOAD: C{int} @ivar brokenPeer: Indicates if the connection is still functional @type brokenPeer: C{int} @ivar _state: Indicates if the protocol is consuming the length portion (C{PARSING_LENGTH}) or the payload (C{PARSING_PAYLOAD}) of a netstring @type _state: C{int} @ivar _remainingData: Holds the chunk of data that has not yet been consumed @type _remainingData: C{string} @ivar _payload: Holds the payload portion of a netstring including the trailing comma @type _payload: C{BytesIO} @ivar _expectedPayloadSize: Holds the payload size plus one for the trailing comma. @type _expectedPayloadSize: C{int} is(0|[1-9]\d*)(:)s (0|[1-9]\d*)$sBThe received netstring does not start with a length specification.spThe length specification of the received netstring cannot be represented in Python - it causes an OverflowError!sQThe received netstring is longer than the maximum %s specified by self.MAX_LENGTHs4The received netstring is not terminated by a comma.icC`sStjj||d|_d|_t|_|j|_d|_ d|_ dS(s+ Initializes the protocol. R iN( RtProtocoltmakeConnectiont_remainingDatat_currentPayloadSizeRt_payloadt_PARSING_LENGTHt_statet_expectedPayloadSizet brokenPeer(tselft transport((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRs     cC`s|jjt|dS(s1 Sends a netstring. Wraps up C{string} by adding length information and a trailing comma; writes the result to the transport. @param string: The string to send. The necessary framing (length prefix, etc) will be added. @type string: C{bytes} N(R'twriteR(R&tstring((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyt sendStrings cC`sa|j|7_xK|jr\y|jWqtk r=Pqtk rX|jPqXqWdS(s= Receives some characters of a netstring. Whenever a complete netstring is received, this method extracts its payload and calls L{stringReceived} to process it. @param data: A chunk of data representing a (possibly partial) netstring @type data: C{bytes} N(Rt _consumeDataRRt_handleParseError(R&R((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyt dataReceiveds     cC`s tdS(s^ Override this for notification when each complete string is received. @param string: The complete string which was received with all framing (length prefix, etc) removed. @type string: C{bytes} @raise NotImplementedError: because the method has to be implemented by the child class. N(tNotImplementedError(R&R)((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pytstringReceiveds cC`stjtj|jdS(s Calculate and return the string size of C{self.MAX_LENGTH}. @return: The size of the string representation for C{self.MAX_LENGTH} @rtype: C{float} i(tmathtceiltlog10t MAX_LENGTH(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyt_maxLengthSizescC`sL|j|jkr)|j|jn|j|jkrH|jndS(s0 Consumes the content of C{self._remainingData}. @raise IncompleteNetstring: if C{self._remainingData} does not contain enough data to complete the current netstring. @raise NetstringParseError: if the received data do not form a valid netstring. N(R#R"t_consumeLengtht_prepareForPayloadConsumptiont_PARSING_PAYLOADt_consumePayload(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR+s   cC`sB|jj|j}|s1|jtn|j|dS(sL Consumes the length portion of C{self._remainingData}. @raise IncompleteNetstring: if C{self._remainingData} contains a partial length specification (digits without trailing comma). @raise NetstringParseError: if the received data do not form a valid netstring. N(t_LENGTHtmatchRt _checkPartialLengthSpecificationRt_processLength(R&t lengthMatch((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR5s   cC`sM|jj|j}|s-t|jn|jd}|j|dS(sA Makes sure that the received data represents a valid number. Checks if C{self._remainingData} represents a number smaller or equal to C{self.MAX_LENGTH}. @raise NetstringParseError: if C{self._remainingData} is no number or is too big (checked by L{extractLength}). iN(t_LENGTH_PREFIXR:RRt_MISSING_LENGTHtgroupt_extractLength(R&tpartialLengthMatchtlengthSpecification((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR;s cC`sU|jd}|jd}|j| }|j|d|_|j||_dS(sY Processes the length definition of a netstring. Extracts and stores in C{self._expectedPayloadSize} the number representing the netstring size. Removes the prefix representing the length specification from C{self._remainingData}. @raise NetstringParseError: if the received netstring does not start with a number or the number is bigger than C{self.MAX_LENGTH}. @param lengthMatch: A regular expression match object matching a netstring length specification @type lengthMatch: C{re.Match} iiN(tendRRAR$(R&R=t endOfNumbert startOfDatat lengthString((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR<s  cC`sH|j|t|}||jkrDt|j|jfn|S(sy Attempts to extract the length information of a netstring. @raise NetstringParseError: if the number is bigger than C{self.MAX_LENGTH}. @param lengthAsString: A chunk of data starting with a length specification @type lengthAsString: C{bytes} @return: The length of the netstring @rtype: C{int} (t_checkStringSizetintR3Rt _TOO_LONG(R&tlengthAsStringtlength((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRAs  cC`s8t||jkr4t|j|jfndS(s> Checks the sanity of lengthAsString. Checks if the size of the length specification exceeds the size of the string representing self.MAX_LENGTH. If this is not the case, the number represented by lengthAsString is certainly bigger than self.MAX_LENGTH, and a NetstringParseError can be raised. This method should make sure that netstrings with extremely long length specifications are refused before even attempting to convert them to an integer (which might trigger a MemoryError). N(RR4RRJR3(R&RK((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRH1scC`s6|j|_d|_|jjd|jjdS(sW Sets up variables necessary for consuming the payload of a netstring. iN(R7R#R R!tseekttruncate(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR6Ds  cC`sL|j|j|jkr(tn|j|j|_|jdS(s Consumes the payload portion of C{self._remainingData}. If the payload is complete, checks for the trailing comma and processes the payload. If not, raises an L{IncompleteNetstring} exception. @raise IncompleteNetstring: if the payload received so far contains fewer characters than expected. @raise NetstringParseError: if the payload does not end with a comma. N(t_extractPayloadR R$Rt_checkForTrailingCommaR"R#t_processPayload(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR8Ns    cC`s|jrR|j|j}|jj|j| |j||_|j|_n4|jj|j|jt|j7_d|_dS(s Extracts payload information from C{self._remainingData}. Splits C{self._remainingData} at the end of the netstring. The first part becomes C{self._payload}, the second part is stored in C{self._remainingData}. If the netstring is not yet complete, the whole content of C{self._remainingData} is moved to C{self._payload}. R N(t_payloadCompleteR$R R!R(RR(R&tremainingPayloadSize((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyROcs  cC`st|j|j|jkS(s  Checks if enough data have been received to complete the netstring. @return: C{True} iff the received data contain at least as many characters as specified in the length section of the netstring @rtype: C{bool} (RRR R$(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRRzs cC`s|j|jjd dS(s Processes the actual payload with L{stringReceived}. Strips C{self._payload} of the trailing comma and calls L{stringReceived} with the result. iN(R/R!tgetvalue(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRQscC`s/|jjddkr+t|jndS(s Checks if the netstring has a trailing comma at the expected position. @raise NetstringParseError: if the last payload character is anything but a comma. iRN(R!RTRt_MISSING_COMMA(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRPscC`s|jjd|_dS(sQ Terminates the connection and sets the flag C{self.brokenPeer}. iN(R'tloseConnectionR%(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR,s (!RRRR3tretcompileR9R>R?t _OVERFLOWRJRUtrangeR"R7RR*R-R/R4R+R5R;R<RARHR6R8RORRRQRPR,(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR9s6>            tLineOnlyReceivercB`sDeZdZdZdZdZdZdZdZdZ RS(s A protocol that receives only lines. This is purely a speed optimisation over LineReceiver, for the cases that raw mode is known to be unnecessary. @cvar delimiter: The line-ending delimiter to use. By default this is C{b'\r\n'}. @cvar MAX_LENGTH: The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped). Default is 16384. R s i@cC`s|j|j|j}|jd|_xM|D]E}|jjrHdSt||jkrj|j|S|j |q2Wt|j|jkr|j|jSdS(sF Translates bytes into lines, and calls lineReceived. iN( t_buffertsplitt delimitertpopR't disconnectingRR3tlineLengthExceededt lineReceived(R&Rtlinestline((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR-s   cC`s tdS(s Override this for when each line is received. @param line: The line which was received with the delimiter removed. @type line: C{bytes} N(R.(R&Rd((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRbscC`s|jj||jfS(s Sends a line to the other end of the connection. @param line: The line to send, not including the delimiter. @type line: C{bytes} (R't writeSequenceR^(R&Rd((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pytsendLinescC`s tjdS(s Called when the maximum line length has been reached. Override if it needs to be dealt with in some special way. sLine length exceeded(R tConnectionLost(R&Rd((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRas( RRRR\R^R3R-RbRfRa(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR[s   t_PauseableMixincB`s)eZeZdZdZdZRS(cC`st|_|jjdS(N(tTruetpausedR'tpauseProducing(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRks cC`s't|_|jj|jddS(NR (tFalseRjR'tresumeProducingR-(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRms  cC`st|_|jjdS(N(RiRjR't stopProducing(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRns (RRRlRjRkRmRn(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRhs  t LineReceivercB`sweZdZdZdZeZdZdZdZ dZ ddZ dZ d Z d Zd Zd ZRS( s A protocol that receives lines and/or raw data, depending on mode. In line mode, each line that's received becomes a callback to L{lineReceived}. In raw data mode, each chunk of raw data becomes a callback to L{rawDataReceived}. The L{setLineMode} and L{setRawMode} methods switch between the two modes. This is useful for line-oriented protocols such as IRC, HTTP, POP, etc. @cvar delimiter: The line-ending delimiter to use. By default this is C{b'\r\n'}. @cvar MAX_LENGTH: The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped). Default is 16384. iR s i@cC`s|jd}|_|S(ss Clear buffered data. @return: All of the cleared buffered data. @rtype: C{bytes} R (R\(R&tb((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pytclearLineBufferscC`s|jr|j|7_dSzRt|_|j|7_x3|jrl|j rl|jr>y%|jj|jd\}|_WnJtk rt|j|j kr|jd}|_|j |SdSXt|}||j kr ||j|j}d|_|j |S|j |}|s7|j ri|j j ri|Sq:|j}d|_|j|}|r:|Sq:WWdt|_XdS(s Protocol.dataReceived. Translates bytes into lines, and calls lineReceived (or rawDataReceived, depending on mode.) NiR (t_busyReceivingR\RiRjt line_modeR]R^t ValueErrorRR3RaRbR'R`trawDataReceivedRl(R&RRdt lineLengthtexceededtwhy((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR-s>             cC`s d|_|r|j|SdS(s Sets the line-mode of this receiver. If you are calling this from a rawDataReceived callback, you can pass in extra unhandled data, and that data will be parsed for lines. Further data received will be sent to lineReceived rather than rawDataReceived. Do not pass extra data if calling this function from within a lineReceived callback. iN(RsR-(R&textra((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyt setLineModeIs cC`s d|_dS(s Sets the raw mode of this receiver. Further data received will be sent to rawDataReceived rather than lineReceived. iN(Rs(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyt setRawModeZscC`s tdS(s> Override this for when raw data is received. N(R.(R&R((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRucscC`s tdS(s Override this for when each line is received. @param line: The line which was received with the delimiter removed. @type line: C{bytes} N(R.(R&Rd((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRbjscC`s|jj||jS(s Sends a line to the other end of the connection. @param line: The line to send, not including the delimiter. @type line: C{bytes} (R'R(R^(R&Rd((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRftscC`s |jjS(sw Called when the maximum line length has been reached. Override if it needs to be dealt with in some special way. The argument 'line' contains the remainder of the buffer, starting with (at least some part) of the line which is too long. This may be more than one line, or may be only the initial portion of the line. (R'RV(R&Rd((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRa~s (RRRRsR\RlRrR^R3RqR-RzR{RuRbRfRa(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRos +   tStringTooLongErrorcB`seZdZRS(sZ Raised when trying to send a string too long for a length prefixed protocol. (RRR(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR|st_RecvdCompatHackcB`seZdZddZRS(sK Emulates the to-be-deprecated C{IntNStringReceiver.recvd} attribute. The C{recvd} attribute was where the working buffer for buffering and parsing netstrings was kept. It was updated each time new data arrived and each time some of that data was parsed and delivered to application code. The piecemeal updates to its string value were expensive and have been removed from C{IntNStringReceiver} in the normal case. However, for applications directly reading this attribute, this descriptor restores that behavior. It only copies the working buffer when necessary (ie, when accessed). This avoids the cost for applications not using the data. This is a custom descriptor rather than a property, because we still need the default __set__ behavior in both new-style and old-style subclasses. cC`s|j|jS(N(t _unprocessedt_compatibilityOffset(R&toselfttype((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyt__get__sN(RRRtNoneR(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR}stIntNStringReceivercB`sMeZdZdZdZdZeZdZdZ dZ dZ RS(s, Generic class for length prefixed protocols. @ivar _unprocessed: bytes received, but not yet broken up into messages / sent to stringReceived. _compatibilityOffset must be updated when this value is updated so that the C{recvd} attribute can be generated correctly. @type _unprocessed: C{bytes} @ivar structFormat: format used for struct packing/unpacking. Define it in subclass. @type structFormat: C{str} @ivar prefixLength: length of the prefix, in bytes. Define it in subclass, using C{struct.calcsize(structFormat)} @type prefixLength: C{int} @ivar _compatibilityOffset: the offset within C{_unprocessed} to the next message to be parsed. (used to generate the recvd attribute) @type _compatibilityOffset: C{int} iR icC`s tdS(s Override this for notification when each complete string is received. @param string: The complete string which was received with all framing (length prefix, etc) removed. @type string: C{bytes} N(R.(R&R)((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR/scC`s|jjdS(s Callback invoked when a length prefix greater than C{MAX_LENGTH} is received. The default implementation disconnects the transport. Override this. @param length: The length prefix which was received. @type length: C{int} N(R'RV(R&RL((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pytlengthLimitExceededs c C`sT|j|}d}|j}|j}||_x t|||kr9|j r9||}t||||!\}||jkr||_||_|j|dS||}t||krPn|||!} |}||_|j | d|j kr1|j j d}||_d|_}|r2q1ndSq1W|||_d|_dS(sL Convert int prefixed strings into calls to stringReceived. iNtrecvd( R~t prefixLengtht structFormatRRjRR3RRR/t__dict__R_( R&Rtalldatat currentOffsetRtfmtt messageStartRLt messageEndtpacket((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR-s:    #           cC`sqt|dd|jkrGtdt|dd|jfn|jjt|jt||dS(s Send a prefixed string to the other end of the connection. @param string: The string to send. The necessary framing (length prefix, etc) will be added. @type string: C{bytes} iis*Try to send %s bytes whereas maximum is %sN(RRR|R'R(RR(R&R)((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR*s $ ( RRRR3R~RR}RR/RR-R*(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRs  2tInt32StringReceivercB`s eZdZdZeeZRS(s A receiver for int32-prefixed strings. An int32 string is a string prefixed by 4 bytes, the 32-bit length of the string encoded in network byte order. This class publishes the same interface as NetstringReceiver. s!I(RRRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR"stInt16StringReceivercB`s eZdZdZeeZRS(s A receiver for int16-prefixed strings. An int16 string is a string prefixed by 2 bytes, the 16-bit length of the string encoded in network byte order. This class publishes the same interface as NetstringReceiver. s!H(RRRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR0stInt8StringReceivercB`s eZdZdZeeZRS(s A receiver for int8-prefixed strings. An int8 string is a string prefixed by 1 byte, the 8-bit length of the string. This class publishes the same interface as NetstringReceiver. s!B(RRRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR>stStatefulStringProtocolcB`seZdZdZdZRS(s A stateful string protocol. This is a mixin for string protocols (L{Int32StringReceiver}, L{NetstringReceiver}) which translates L{stringReceived} into a callback (prefixed with C{'proto_'}) depending on state. The state C{'done'} is special; if a C{proto_*} method returns it, the connection will be closed immediately. @ivar state: Current state of the protocol. Defaults to C{'init'}. @type state: C{str} tinitcC`s|y d|j}t||}Wn'tk rItjd|jdn/X|||_|jdkrx|jjndS(s Choose a protocol phase function and call it. Call back to the appropriate protocol phase; this begins with the function C{proto_init} and moves on to C{proto_*} depending on what each C{proto_*} function returns. (For example, if C{self.proto_init} returns 'foo', then C{self.proto_foo} will be the next function called when a protocol message is received. tproto_tcallbacks not foundtdoneN(tstatetgetattrtAttributeErrorR tmsgR'RV(R&R)tptot statehandler((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyR/]s   (RRRRR/(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRLs t FileSendercB`sGeZdZdZdZd Zd dZdZdZ dZ RS( s A producer that sends the contents of a file to a consumer. This is a helper for protocols that, at some point, will take a file-like object, read its contents, and write them out to the network, optionally performing some transformation on the bytes in between. iiR cC`sE||_||_||_tj|_}|jj|t|S(s Begin transferring a file @type file: Any file-like object @param file: The file object to read data from @type consumer: Any implementor of IConsumer @param consumer: The object to write data to @param transform: A callable taking one string argument and returning the same. All bytes read from the file are passed through this before being written to the consumer. @rtype: C{Deferred} @return: A deferred whose callback will be invoked when the file has been completely written to the consumer. The last byte written to the consumer is passed to the callback. (tfiletconsumert transformR tDeferredtdeferredtregisterProducerRl(R&RRRR((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pytbeginFileTransfers    cC`sd}|jr'|jj|j}n|sod|_|jj|jrk|jj|jd|_ndS|j r|j |}n|jj ||d|_dS(NR i( Rtreadt CHUNK_SIZERRtunregisterProducerRRtlastSentRR((R&tchunk((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRms      cC`sdS(N((R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRkscC`s/|jr+|jjtdd|_ndS(Ns#Consumer asked us to stop producing(Rterrbackt ExceptionR(R&((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRns   i@N( RRRRRRRRRmRkRn(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyRss   (-Rt __future__RRRWtstructRRRtioRR0tzope.interfaceRttwisted.python.compatRttwisted.internetRR R R ttwisted.pythonR RtDEBUGRtRRRRRR[RhRotAssertionErrorR|tobjectR}RRRRRt IProducerR(((s;/usr/lib/python2.7/dist-packages/twisted/protocols/basic.pyts:  "   mCy'