-=[ Mr. Bumblebee ]=-
_Indonesia_

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


	_Oc@@s,dZddlmZdddgZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZd	efd
YZdejfdYZdefdYZd
efdYZdefdYZdefdYZdejfdYZdZdS(sRemoteTransport client for the smart-server.

This module shouldn't be accessed directly.  The classes defined here should be
imported from bzrlib.smart.
i(tabsolute_importtRemoteTransporttRemoteTCPTransporttRemoteSSHTransport(tStringIO(tconfigtdebugterrorstremotettracet	transportturlutils(tclienttmediumt
_SmartStatcB@seZdZRS(cC@s||_||_dS(N(tst_sizetst_mode(tselftsizetmode((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt__init__+s	(t__name__t
__module__R(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyR)scB@seZdZd)Zd*d*d*dZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZd*dZd*dZd*dZd*ed*dZd*dZd*ed*dZd*dZd*dZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d*d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*RS(+sBConnection to a smart server.

    The connection holds references to the medium that can be used to send
    requests to the server.

    The connection has a notion of the current directory to which it's
    connected; this is incorporated in filenames passed to the server.

    This supports some higher-level RPC operations and can also be treated
    like a Transport to do file-like operations.

    The connection can be made over a tcp socket, an ssh pipe or a series of
    http requests.  There are concrete subclasses for each type:
    RemoteTCPTransport, etc.
    iicC@stt|j|d||dk	rCt|trC|j}n|dkrd}|dkr|j\}}dtjkrt	j
d|jjqnt
j|||j|_n1|dkr|jj}ntd||f|dkrtj||_n	||_dS(sConstructor.

        :param _from_transport: Another RemoteTransport instance that this
            one is being cloned from.  Attributes such as the medium will
            be reused.

        :param medium: The medium to use for this RemoteTransport.  If None,
            the medium from the _from_transport is shared.  If both this
            and _from_transport are None, a new medium will be built.
            _from_transport and medium cannot both be specified.

        :param _client: Override the _SmartClient used by this transport.  This
            should only be used for testing purposes; normally this is
            determined from the medium.
        t_from_transportthpssshpss: Built a new medium: %ssyBoth _from_transport (%r) and medium (%r) passed to RemoteTransport.__init__, but these parameters are mutally exclusive.N(tsuperRRtNonet
isinstancet_clientt
_build_mediumRtdebug_flagsR	tmuttert	__class__RR
t_SharedConnectiontbaset_shared_connectiont
connectiontAssertionErrorRt_SmartClient(RturlRR
Rtcredentials((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRNs.
		cC@sdS(sCreate the medium if _from_transport does not provide one.

        The medium is analogous to the connection for ConnectedTransport: it
        allows connection sharing.
        N(NN(R(R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRscC@sdS(sSee Transport._report_activity.

        Does nothing; the smart medium will report activity triggered by a
        RemoteTransport.
        N((Rtbytest	direction((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt_report_activityscC@s^y|jd}Wntjk
r*tSX|dkr;tS|dkrKtStj|dS(s9Smart server transport can do read/write file operations.sTransport.is_readonlytyestnoN(syes(sno(t_call2RtUnknownSmartMethodtFalsetTruetUnexpectedSmartServerResponse(Rtresp((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytis_readonlyscC@s
|jS(N(t_get_connection(R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytget_smart_clientscC@s
|jS(N(R5(R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytget_smart_mediumscC@stjj|jj|S(s=Returns the Unicode version of the absolute path for relpath.(RtURLt_combine_pathst_parsed_urltpath(Rtrelpath((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt_remote_pathscG@s#|j||}|j|dS(N(R.t
_ensure_ok(RtmethodtargsR3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt_callscG@sdy|jj||SWnFtjk
r_}|rFi|dd6}ni}|j||nXdS(s#Call a method on the remote server.iR<N(RtcallRtErrorFromSmartServert_translate_error(RR?R@terrtcontext((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyR.scC@sgy|jj|||SWnFtjk
rb}|rIi|dd6}ni}|j||nXdS(s3Call a method on the remote server with body bytes.iR<N(Rtcall_with_body_bytesRRCRD(RR?R@tbodyRERF((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt_call_with_body_bytesscC@sN|jd|j|}|dkr+tS|dkr;tStj|dS(sgIndicate whether a remote file of the given name exists or not.

        :see: Transport.has()
        thasR,R-N(syes(sno(R.R=R1R0RR2(RR<R3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRJscC@st|j|S(swReturn file-like object reading the contents of a remote file.

        :see: Transport.get_bytes()/get_file()
        (Rt	get_bytes(RR<((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytgetscC@s|j|}y|jjd|\}}Wn&tjk
rV}|j||nX|dkr|jtj|n|jS(NRLtok(sok(	R=Rtcall_expecting_bodyRRCRDtcancel_read_bodyR2tread_body_bytes(RR<RR3tresponse_handlerRE((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRKs
cC@s|dkrdSd|SdS(Nts%d(R(RR((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt_serialise_optional_modescC@s+|jd|j||j|}dS(Ntmkdir(R.R=RS(RR<RR3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRTscC@s?|j|d|tj||}|tj|j|<|S(s See Transport.open_write_stream.RR(t	put_bytesR
tAppendBasedFileStreamt
_file_streamstabspath(RR<Rtresult((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytopen_write_streamscC@sqt|tkr-td|dddn|jd|j||j|f|}|j|t|S(Nt	undefinediis+put_bytes must be given bytes, not unicode.tput(ttypetunicodetUnicodeEncodeErrorRIR=RSR>tlen(RR<tupload_contentsRR3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRUs		
cC@sbd}|rd}n|jd|j||j|||j|f|}|j|dS(s#See Transport.put_bytes_non_atomic.tFtTtput_non_atomicN(RIR=RSR>(RR<R)Rtcreate_parent_dirtdir_modetcreate_parent_strR3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytput_bytes_non_atomic
s		cC@sG|j}y|j||j|SWn|j|nXdS(N(ttellRUtreadtseek(RR<tupload_fileRtpos((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytput_files
c	C@s(|j||jd|d|d|S(NRReRf(RhRj(RR<tfRReRf((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytput_file_non_atomic%scC@s|j||j|S(N(tappend_bytesRj(RR<t	from_fileR((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytappend_file,scC@s^|jd|j||j|f|}|ddkrKt|dStj|dS(Ntappenditappendedi(RIR=RStintRR2(RR<R)RR3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRq/s	cC@s,|jd|j|}|j|dS(Ntdelete(R.R=R>(RR<R3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRw8scC@s|jS(s,See bzrlib.transport.Transport.external_url.(R"(R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytexternal_url<scC@sdS(s4Return the recommended page size for this transport.i@ii((R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytrecommended_page_sizeAsc
c@s>|s
dSt|}t|}t|j|d|jd|jd|j}g}g}d}xc|D][}|j||jkr|j||g}|j}qkn|j|||j7}qkW|r|j|ndtj	kr5t
jd|jj
t|t|t|ttt|ni}	t|}
|
jg}x|D]}yS|jjd|j|fg|D]}|j|jf^q}|\}
}Wn&tjk
r}|j||nX|
ddkr|jtj|
nx(|j|
|||	|D]}|Vq'Wq]WdS(Ntlimittfudge_factortmax_sizeiRs7%s.readv %s offsets => %s coalesced => %s requests (%s)treadv(tlisttsortedt_coalesce_offsetst_max_readv_combinet_bytes_to_read_before_seekt_max_readv_bytestlengthRtRRR	RR RR`tsumtmaptitertnextRtcall_with_body_readv_arrayR=tstartRRCRDROR2t_handle_response(RR<toffsetstsorted_offsetst	coalescedtrequeststcur_requesttcur_lentctdata_maptoffset_stacktnext_offsetRYR3RQREtres((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt_readvEsX		

		
	"
	(

cc@sD|d}|j}d}x!|D]}	t||	jkrhtjt|	j|	jdt|nx|	jD]t\}
}|	j|
|f}|||
||
|!}
||kr|d|
fV|j}|d<qr|
||<qrW||	j7}xB||kr;|j	|}
|d|
fV|j}|d<qWq#WdS(Nitactual(
RPR`RRtShortReadvErrorR<RtrangesRtpop(RRRRQRRtcur_offset_and_sizetdatatdata_offsettc_offsett	suboffsettsubsizetkeyt	this_data((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyR~s(



cC@s)|jd|j||j|dS(Ntrename(RAR=(Rtrel_fromtrel_to((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs	cC@s)|jd|j||j|dS(Ntmove(RAR=(RRR((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs	cC@s|jd|j|}dS(Ntrmdir(RAR=(RR<R3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRscC@s&|ddkr"tj|ndS(NiRM(RR2(RR3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyR>scC@stj|d|dS(NR;(RRD(RRER<((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRDscC@s)|j}|dk	r%|jndS(N(R7Rt
disconnect(Rtm((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRscC@sb|jd|j|}|ddkrOtt|dt|ddStj|dS(Ntstatiiii(R.R=RRvRR2(RR<R3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs$cC@stS(N(R1(R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytlistablescC@sb|jd|j|}|ddkrOg|dD]}|jd^q6Stj|dS(Ntlist_diritnamesitascii(R.R=tencodeRR2(RR<R3tname((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs$cC@sF|jd|jd}|ddkr3|dStj|dS(Ntiter_files_recursiveRRiRi(R.R=RR2(RR3((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRsiiPN(+RRt__doc__RRRRR+R4R6R7R=RAR.RIRJRLRKRSRTRZRUR0RhRnRpRsRqRwRxRyRRRRRR>RDRRRRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyR0sV5											
								9	"								cB@seZdZdZRS(sConnection to smart server over plain tcp.

    This is essentially just a factory to get 'RemoteTransport(url,
        SmartTCPClientMedium).
    cC@s.tj|jj|jj|j}|dfS(N(R
tSmartTCPClientMediumR:thosttportR"R(Rt
client_medium((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs(RRRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRstRemoteTCPTransportV2OnlycB@seZdZdZRS(sConnection to smart server over plain tcp with the client hard-coded to
    assume protocol v2 and remote server version <= 1.6.

    This should only be used for testing.
    cC@sDtj|jj|jj|j}d|_|jd|dfS(Niii(ii(	R
RR:RRR"t_protocol_versiont_remember_remote_is_beforeR(RR((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs
	
(RRRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRscB@seZdZdZRS(sConnection to smart server over SSH.

    This is essentially just a factory to get 'RemoteTransport(url,
        SmartSSHClientMedium).
    cC@stj|j}|j}|jj}|dkrftj}|jd|jj	|jj
}ntj|jj	|jj
||jj
|}tj|j|}|||jj
ffS(Ntssh(RtLocationConfigR"tget_bzr_remote_pathR:tuserRtAuthenticationConfigtget_userRRR
t	SSHParamstpasswordtSmartSSHClientMedium(Rtlocation_configtbzr_remote_pathRtautht
ssh_paramsR((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs	(RRRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRstRemoteHTTPTransportcB@sAeZdZdddZdZdZdZdZRS(sJust a way to connect between a bzr+http:// url and http://.

    This connection operates slightly differently than the RemoteSSHTransport.
    It uses a plain http:// transport underneath, which defines what remote
    .bzr/smart URL we are connected to. From there, all paths that are sent are
    sent as relative paths, this way, the remote side can properly
    de-reference them, since it is likely doing rewrite rules to translate an
    HTTP path into a local path.
    cC@sZ|dkr1|td}tj||_n	||_tt|j|d|dS(Nsbzr+R(RR`R
tget_transport_from_urlt_http_transportRRR(RR"Rthttp_transportthttp_url((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs	cC@s|jjdfS(N(RR7R(R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyR%scC@sVtj|jj}tj|jtd|}tj|}tj||S(s=After connecting, HTTP Transport only deals in relative URLs.sbzr+(Rt
normalize_urlR7R"tjoinR`trelative_url(RR<t	http_baseR'((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyR=)scC@s:|r|j|}n	|j}t|d|d|jS(sMMake a new RemoteHTTPTransport related to me.

        This is re-implemented rather than using the default
        RemoteTransport.clone() because we must be careful about the underlying
        http transport.

        Also, the cloned smart transport will POST to the same .bzr/smart
        location as this transport (although obviously the relative paths in the
        smart requests may be different).  This is so that the server doesn't
        have to handle .bzr/smart requests at arbitrary places inside .bzr
        directories, just at the initial URL the user uses.
        RR(RXR"RR(RRtabs_url((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytclone2s
		cC@s[|jj||}|dk	rSt|t|jrStd|jd|S|SdS(sSee transport._redirected_tosbzr+RN(Rt_redirected_toRRR]RRx(Rtsourcettargett
redirected((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRGsN(	RRRRRRR=RR(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRs					tHintingSSHTransportcB@seZdZdZRS(s?Simple transport that handles ssh:// and points out bzr+ssh://.cC@stj|d|dS(Ns7bzr supports bzr+ssh to operate over ssh, use "bzr+%s".(RtUnsupportedProtocol(RR'((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRVs	(RRRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyRSscC@s ddlm}t|jfgS(s4Return (transport, server) permutations for testing.i(ttest_server(tbzrlib.testsRRtSmartTCPServer_for_testing(R((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pytget_test_permutations[sN(Rt
__future__Rt__all__t	cStringIORtbzrlibRRRRR	R
Rtbzrlib.smartRR
tobjectRtConnectedTransportRRRRRt	TransportRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/transport/remote.pyt<module>s4	
E

Copyright © 2017 || Recoded By Mr.Bumblebee