-=[ Mr. Bumblebee ]=-
_Indonesia_

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

๓
S:งQc@@sโddlmZddlmZejeƒdƒddlZddlmZmZddlmZm	Z	m
Z
mZdefd„ƒYZ
d	efd
„ƒYZde
jfd„ƒYZeƒe
_
d
efd„ƒYZdS(i(tabsolute_import(tlazy_imports2
from bzrlib.smart import request as _mod_request
N(tmessagetprotocol(tdebugterrorsthooksttracet_SmartClientcB@sqeZd
d„Zd„Zd
d
d
ed„Zd„Zd„Zd„Z	d„Z
d„Zd„Zd	„Z
RS(cC@s>||_|dkr+itjd6|_nt|ƒ|_dS(sAConstructor.

        :param medium: a SmartClientMedium
        sSoftware versionN(t_mediumtNonetbzrlibt__version__t_headerstdict(tselftmediumtheaders((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt__init__$s	cC@sd|jj|jfS(Ns%s(%r)(t	__class__t__name__R	(R((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt__repr__/scC@s4t|||d|d|d|d|ƒ}|jƒS(Ntbodyt
readv_bodytbody_streamtexpect_response_body(t_SmartClientRequesttcall_and_read_response(RtmethodtargsRRRRtrequest((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt_call_and_read_response2s	cG@s&|j||Œ\}}|jƒ|S(s#Call a method on the remote server.(tcall_expecting_bodytcancel_read_body(RRRtresultR((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pytcall9s
cG@s|j||dtƒS(sํCall a method and return the result and the protocol object.

        The body can be read like so::

            result, smart_protocol = smart_client.call_expecting_body(...)
            body = smart_protocol.read_body_bytes()
        R(RtTrue(RRR((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR ?scC@sฑt|ƒtk	r(td|fƒ‚nx6|D].}t|ƒtk	r/td|fƒ‚q/q/Wt|ƒtk	r‰td|fƒ‚n|j||d|dtƒ\}}|S(s3Call a method on the remote server with body bytes.s$method must be a byte string, not %rs!args must be byte strings, not %rs body must be byte string, not %rRR(ttypetstrt	TypeErrorRtFalse(RRRRtargtresponsetresponse_handler((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pytcall_with_body_bytesJs
cC@sทt|ƒtk	r(td|fƒ‚nx6|D].}t|ƒtk	r/td|fƒ‚q/q/Wt|ƒtk	r‰td|fƒ‚n|j||d|dtƒ\}}||fS(s3Call a method on the remote server with body bytes.s$method must be a byte string, not %rs!args must be byte strings, not %rs body must be byte string, not %rRR(R%R&R'RR$(RRRRR)R*R+((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt#call_with_body_bytes_expecting_bodyWs
cC@s6|j|d|dd|dtƒ\}}||fS(NiiRR(RR$(RRRR*R+((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pytcall_with_body_readv_arrayds&cC@s6|j|d|dd|dtƒ\}}||fS(NiiRR(RR((RRtstreamR*R+((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pytcall_with_body_streamiscC@s|jj|ƒS(sConvert transport into a path suitable for using in a request.

        Note that the resulting remote path doesn't encode the host name or
        anything but path, so it is only safe to use it in requests sent over
        the medium from the matching transport.
        (R	tremote_path_from_transport(Rt	transport((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR1osN(Rt
__module__R
RRR$RR#R R,R-R.R0R1(((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR"s				
	
		RcB@skeZdZd
d
d
ed„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd„Zd	„Z
RS(s๏Encapsulate the logic for a single request.

    This class handles things like reconnecting and sending the request a
    second time when the connection is reset in the middle. It also handles the
    multiple requests that get made if we don't know what protocol the server
    supports yet.

    Generally, you build up one of these objects, passing in the arguments that
    you want to send to the server, and then use 'call_and_read_response' to
    get the response from the server.
    cC@sC||_||_||_||_||_||_||_dS(N(tclientRRRRRR(RR4RRRRRR((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR†s						cC@s@|jƒ|jjj}|dkr/|jƒS|j|ƒSdS(sPSend the request to the server, and read the initial response.

        This doesn't read all of the body content of the response, instead it
        returns (response_tuple, response_handler). response_tuple is the 'ok',
        or 'error' information, and 'response_handler' can be used to get the
        content stream out.
        N(t_run_call_hooksR4R	t_protocol_versionR
t"_call_determining_protocol_versiont_call(Rtprotocol_version((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRs


cC@su|jd	k	sdtjkr"tStjj|jƒ}|d
krGt	S|dkrWtSt
jd||jfƒtS(s/Check if the current method is re-entrant safe.tnoretrytreadtidemtsemitsemivfstmutateR/s&Unknown request type: %s for method %sN(sreadR<R=(R>R?sstream(RR
Rtdebug_flagsR(t_mod_requesttrequest_handlerstget_infoRR$Rtmutter(Rtrequest_type((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt_is_safe_to_send_twiceŸs	cC@satjdsdSt|j|j|j|j|jjƒ}xtjdD]}||ƒqIWdS(NR#(	RRtCallHookParamsRRRRR4R	(Rtparamsthook((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR5ฏs
cC@sล|j|ƒ}y|jd|jƒ}Wntjk
rบ}|jjjƒ|jƒs_‚nt	j
d|jfƒt	jƒ|j
|ƒ\}}|j|ƒ|jd|jƒ}nX||fS(sยWe know the protocol version.

        So this just sends the request, and then reads the response. This is
        where the code will be to retry requests if the connection is closed.
        texpect_bodys1ConnectionReset reading response for %r, retrying(t_sendtread_response_tupleRRtConnectionResetR4R	tresetRFRtwarningRtlog_exception_quietlyt_construct_protocolt_send_no_retry(RR9R+tresponse_tupletetencoder((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR8ทs"		

	cC@sํxอddgD]ฟ}|dkr5|jjjdƒny|j|ƒ\}}Wnbtjk
r}tjd|fƒ|jjjƒq
q
tj	k
rฒ||jj_
‚q
X||jj_
||fSq
Wtjdt|ƒƒ‚dS(	sฬDetermine what protocol the remote server supports.

        We do this by placing a request in the most recent protocol, and
        handling the UnexpectedProtocolVersionMarker from the server.
        iiiisiServer does not understand Bazaar network protocol %d, reconnecting.  (Upgrade the server to avoid this.)sServer is not a Bazaar server: N(ii(
R4R	t_remember_remote_is_beforeR8RtUnexpectedProtocolVersionMarkerRROt
disconnecttErrorFromSmartServerR6tSmartProtocolErrorR&(RR9RSR+terr((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR7ฯs$cC@sค|jjjƒ}|dkratj|ƒ}tjƒ}tj|dtƒ}|j	||ƒn9|dkr…tj
|ƒ}|}ntj|ƒ}|}||fS(s6Build the encoding stack for a given protocol version.itexpect_version_markeri(R4R	tget_requestRtProtocolThreeRequesterRtConventionalResponseHandlertProtocolThreeDecoderR$tsetProtoAndMediumRequesttSmartClientRequestProtocolTwotSmartClientRequestProtocolOne(RtversionRtrequest_encoderR+tresponse_proto((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRQ๏s	cC@sร|j|ƒ\}}y|j|ƒWn–tjk
rพ}|jjjƒdtjksr|j	dk	rx|jrx‚ntj
d|jfƒtjƒ|j|ƒ\}}|j|ƒnX|S(s_Encode the request, and send it to the server.

        This will retry a request if we get a ConnectionReset while sending the
        request to the server. (Unless we have a body_stream that we have
        already started consuming, since we can't restart body_streams)

        :return: response_handler as defined by _construct_protocol
        R:s$ConnectionReset calling %r, retryingN(RQRRRRMR4R	RNRR@RR
tbody_stream_startedRRORRP(RR9RUR+RT((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRKs 			
cC@s|j|jjƒ|jdk	r|jdk	r@tdƒ‚n|jdk	r^tdƒ‚n|j|j	f|j
|jƒn˜|jdk	rั|jdk	rฎtdƒ‚n|j|j	f|j
|jƒnH|jdk	r|j|j	f|j
|jƒn|j
|j	|j
ŒdS(s+Just encode the request and try to send it.s+body and readv_body are mutually exclusive.s,body and body_stream are mutually exclusive.s2readv_body and body_stream are mutually exclusive.N(tset_headersR4R
RR
RtAssertionErrorRR,RRR.R0R#(RRU((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRR&s&#

N(RR3t__doc__R
R$RRRFR5R8R7RQRKRR(((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRys						 		&tSmartClientHookscB@seZd„ZRS(cC@s-tjj|ddƒ|jdddƒdS(Nsbzrlib.smart.clients_SmartClient.hooksR#sฟCalled when the smart client is submitting a request to the smart server. Called with a bzrlib.smart.client.CallHookParams object. Streaming request bodies, and responses, are not accessible.(RtHooksRtadd_hookR
(R((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyR@s	(RR3R(((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRk>sRGcB@s,eZd„Zd„Zd„Zd„ZRS(cC@s1||_||_||_||_||_dS(N(RRRRR(RRRRRR((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRNs
				cC@s3td„|jjƒDƒƒ}d|jj|fS(Ncs@s-|]#\}}|dk	r||fVqdS(N(R
(t.0tktv((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pys	<genexpr>Vs	s<%s %r>(Rt__dict__t	iteritemsRR(Rtattrs((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRUscC@s,t|ƒt|ƒk	rtS|j|jkS(N(R%tNotImplementedRq(Rtother((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt__eq__ZscC@s||kS(N((RRu((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt__ne___s(RR3RRRvRw(((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyRGLs			(t
__future__RRRtglobalstbzrlib.smartRRRRRRtobjectRRRlRkRG(((s7/usr/lib/python2.7/dist-packages/bzrlib/smart/client.pyt<module>s"Wล

Copyright © 2017 || Recoded By Mr.Bumblebee