-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/smart/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyc

ó
¦îNc@@sºddlmZddlZddlmZddlmZmZddlm	Z	de
fd„ƒYZdefd	„ƒYZd
e
fd„ƒYZ
dee
fd
„ƒYZd„ZdS(i(tabsolute_importN(tStringIO(tdebugterrors(tmuttertMessageHandlercB@sMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(sªBase class for handling messages received via the smart protocol.

    As parts of a message are received, the corresponding PART_received method
    will be called.
    cC@s
d|_dS(N(tNonetheaders(tself((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyt__init__$scC@s
||_dS(syCalled when message headers are received.

        This default implementation just stores them in self.headers.
        N(R(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pytheaders_received'scC@st|jƒ‚dS(sŠCalled when a 'byte' part is received.

        Note that a 'byte' part is a message part consisting of exactly one
        byte.
        N(tNotImplementedErrort
byte_received(Rtbyte((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pytbyte_part_received.scC@st|jƒ‚dS(sÇCalled when a 'bytes' part is received.

        A 'bytes' message part can contain any number of bytes.  It should not
        be confused with a 'byte' part, which is always a single byte.
        N(Rtbytes_received(Rtbytes((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pytbytes_part_received6scC@st|jƒ‚dS(sµCalled when a 'structure' part is received.

        :param structure: some structured data, which will be some combination
            of list, dict, int, and str objects.
        N(RR(Rt	structure((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pytstructure_part_received>scC@s‚dS(szCalled when there is a protocol decoding error.

        The default implementation just re-raises the exception.
        N((Rt	exception((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pytprotocol_errorFscC@sdS(s/Called when the end of the message is received.N((R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pytend_receivedMs(
t__name__t
__module__t__doc__R	R
RRRRR(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRs						tConventionalRequestHandlercB@sVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
RS(	s­A message handler for "conventional" requests.

    "Conventional" is used in the sense described in
    doc/developers/network-protocol.txt: a simple message with arguments and an
    optional body.

    Possible states:
     * args: expecting args
     * body: expecting body (terminated by receiving a post-body status)
     * error: expecting post-body error
     * end: expecting end of message
     * nothing: finished
    cC@s>tj|ƒ||_||_d|_t|_t|_dS(Ntargs(RR	trequest_handlert	respondert	expectingtFalset_should_finish_bodyt_response_sent(RRR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR	bs
				cC@s$|jjrdS|jj|ƒdS(N(Rt
response_sentt
send_error(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRjscC@sr|jdkrX|dkr'd|_qn|dkr?d|_qntjd|fƒ‚ntjd|fƒ‚dS(NtbodytStendtEterrors+Non-success status byte in request body: %rs!Unexpected message part: byte(%r)(RRtSmartProtocolError(RR
((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRqscC@sX|jdkr|j|ƒn5|jdkr>|j|ƒntjd|fƒ‚dS(NRR(s&Unexpected message part: structure(%r)(Rt_args_receivedt_error_receivedRR)(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR€scC@sTd|_|jj|ƒ|jjrPt|_|jj|jjƒd|_ndS(NR$R&(	RRt
args_receivedtfinished_readingtTrueR!Rt
send_responsetresponse(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR*‰s		cC@sd|_|jj|ƒdS(NR&(RRtpost_body_error_received(Rt
error_args((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR+‘s	cC@sE|jdkr+t|_|jj|ƒntjd|fƒ‚dS(NR$s"Unexpected message part: bytes(%r)(RR.R Rtaccept_bodyRR)(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR•s
	cC@s…|jdkr+tjd|jfƒ‚nd|_|jjƒ|jjs_tjdƒ‚n|js|jj|jj	ƒndS(NR$R&s8End of message received prematurely (while expecting %s)tnothingsYComplete conventional request was received, but request handler has not finished reading.(sbodysend(
RRR)RRR-R!RR/R0(R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRs	
	(RRRR	RRRR*R+RR(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRSs
								tResponseHandlercB@s8eZdZed„Zdd„Zd„Zd„ZRS(s@Abstract base class for an object that handles a smart response.cC@st|jƒ‚dS(sšReads and returns the response tuple for the current request.

        :keyword expect_body: a boolean indicating if a body is expected in the
            response.  Some protocol versions needs this information to know
            when a response is finished.  If False, read_body_bytes should
            *not* be called afterwards.  Defaults to False.
        :returns: tuple of response arguments.
        N(Rtread_response_tuple(Rtexpect_body((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR6¯s	iÿÿÿÿcC@st|jƒ‚dS(sÚRead and return some bytes from the body.

        :param count: if specified, read up to this many bytes.  By default,
            reads the entire body.
        :returns: str of bytes from the response body.
        N(Rtread_body_bytes(Rtcount((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR8ºscC@st|jƒ‚dS(sLReturns an iterable that reads and returns a series of body chunks.
        N(Rtread_streamed_body(R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR:ÃscC@st|jƒ‚dS(sQStop expecting a body for this response.

        If expect_body was passed to read_response_tuple, this cancels that
        expectation (and thus finishes reading the response, allowing a new
        request to be issued).  This is useful if a response turns out to be an
        error rather than a normal result with a body.
        N(Rtcancel_read_body(R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR;Ès(RRRRR6R8R:R;(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR5¬s
		tConventionalResponseHandlercB@sƒeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
ed	„Zd
d„Z
d„Zd
„ZRS(cC@s_tj|ƒd|_d|_tjƒ|_t|_	d|_
d|_d|_t|_
dS(N(RR	RtstatusRtcollectionstdequet_bytes_partsRt
_body_startedt_body_stream_statust_bodyt_body_error_argsR-(R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR	Õs
						cC@s||_||_dS(N(t_protocol_decodert_medium_request(Rtprotocol_decodertmedium_request((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pytsetProtoAndMediumRequestàs	cC@s—|dkr%tjd|fƒ‚n|jrb|jdk	rVtjd|fƒ‚n||_n1|jdk	rŠtjd|fƒ‚n||_dS(NR'R%sUnknown response status: %rs!Unexpected byte part received: %r(R'R%(RR)RARBRR=(RR
((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRäs	cC@st|_|jj|ƒdS(N(R.RAR@tappend(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRós	cC@s£t|ƒtk	r+tjd|fƒ‚n|jsn|jdk	rbtjd||jfƒ‚n||_n1|jdkr–tjd|fƒ‚n||_dS(Ns$Args structure is not a sequence: %rs2Unexpected structure received: %r (already got %r)R's,Unexpected structure received after body: %r(	ttypettupleRR)RARRRBRD(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR÷s	cC@s.x'|jdkr)|jr)|jƒqWdS(N(RRR-t
_read_more(R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyt_wait_for_response_argsscC@sx|js|jƒqWdS(N(R-RM(R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyt_wait_for_response_endscC@s±|jjƒ}|dkr5t|_|jjƒdS|jj|ƒ}|dkrdtjkr‹td|jj	ƒd |jj
jƒntj
dƒ‚n|jj|ƒdS(Nitthpsss+decoder state: buf[:10]=%r, state_accept=%si
skUnexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.(REtnext_read_sizeR.R-RFt
read_bytesRtdebug_flagsRt_get_in_buffertstate_acceptRRtConnectionResettaccept_bytes(RRRR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRMs	
cC@st|_|jjƒ‚dS(N(R.R-RF(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR%s	
cC@su|jƒ|s|jƒndtjkr?td|jƒn|jdkrh|jƒt|jƒnt|jƒS(s$Read a response tuple from the wire.RQs   result:   %rR'(	RNRORRTRRR=t_raise_smart_server_errorRL(RR7((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR6+s


iÿÿÿÿcC@s{|jdkrk|jƒdj|jƒ}dtjkrPtdt|ƒƒnt	|ƒ|_d|_n|jj
|ƒS(sERead bytes from the body, decoding into a byte stream.

        We read all bytes at once to ensure we've checked the trailer for
        errors, and then feed the buffer back as read_body_bytes is called.

        Like the builtin file.read in Python, a count of -1 (the default) means
        read the entire body.
        RPRQs               %d body bytes readN(RCRROtjoinR@RRTRtlenRtread(RR9t
body_bytes((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR87s
cc@s†x`|jsbxF|jrT|jjƒ}dtjkrLtdt|ƒƒn|VqW|jƒqW|jdkr‚t	|j
ƒndS(Nt
hpssdetails              %d byte part readR'(R-R@tpopleftRRTRR[RMRBRYRD(Rt
bytes_part((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR:Ks	cC@s|jƒdS(N(RO(R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR;Vs(RRR	RIRRRRNRORMRRR6R8R:R;(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyR<Ós										cC@s9|ddkr&tj|dƒ‚ntj|ƒ‚dS(s‹Raise exception based on tuple received from smart server

    Specific error translation is handled by bzrlib.remote._translate_error
    it
UnknownMethodiN(RtUnknownSmartMethodtErrorFromSmartServer(terror_tuple((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyRYZs(t
__future__RR>t	cStringIORtbzrlibRRtbzrlib.traceRtobjectRRR5R<RY(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/message.pyt<module>s6Y'‡

Copyright © 2017 || Recoded By Mr.Bumblebee