403Webshell
Server IP : 61.19.30.66  /  Your IP : 216.73.216.15
Web Server : Apache/2.2.22 (Ubuntu)
System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64
User : www-data ( 33)
PHP Version : 5.3.10-1ubuntu3.48
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python2.7/dist-packages/landscape/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/landscape/lib/amp.pyc
ó
}9Rc@sždZddlmZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
mZmZmZmZmZmZddlmZmZmZde
fd	„ƒYZd
efd„ƒYZdefd
„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZ defd„ƒYZ!defd„ƒYZ"defd„ƒYZ#de	fd„ƒYZ$dS(s>Expose the methods of a remote object over AMP.

This module implements an AMP-based protocol for performing remote procedure
calls in a convenient and easy way. It's conceptually similar to DBus in that
it supports exposing a Python object to a remote process, with communication
happening over any Twisted-supported transport, e.g. Unix domain sockets.

For example let's say we have a Python process "A" that creates an instance of
this class::

    class Greeter(object):

        def hello(self, name):
            return "hi %s!" % name

    greeter = Greeter()

Process A can "publish" the greeter object by defining which methods are
exposed remotely and opening a Unix socket for incoming connections::

    factory = MethodCallServerFactory(greeter, ["hello"])
    reactor.listenUNIX("/some/socket/path", factory)

Then a second Python process "B" can connect to that socket and build a
"remote" greeter object, i.e. a proxy that forwards method calls to the
real greeter object living in process A::

    factory = MethodCallClientFactory()
    reactor.connectUNIX("/some/socket/path", factory)

    def got_remote(remote_greeter):
        deferred = remote_greeter.hello("Ted")
        deferred.addCallback(lambda result: ... # result == "hi Ted!")

    factory.getRemoteObject().addCallback(got_remote)

Note that when invoking a method via the remote proxy, the parameters
are required to be serializable with bpickle, so they can be sent over
the wire.

See also::

    http://twistedmatrix.com/documents/current/core/howto/amp.html

for more details about the Twisted AMP protocol.
iÿÿÿÿ(tuuid4(tDeferredt
maybeDeferredtsucceed(t
ServerFactorytReconnectingClientFactory(tFailure(tArgumenttStringtIntegertCommandtAMPtMAX_VALUE_LENGTHtCommandLocator(tloadstdumpstdumps_tabletMethodCallArgumentcBs/eZdZd„Zd„Zed„ƒZRS(sA bpickle-compatible argument.cCs
t|ƒS(sSerialize an argument.(R(tselftinObject((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyttoString>scCs
t|ƒS(sUnserialize an argument.(R(RtinString((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyt
fromStringBscCst|ƒtkS(s%Check if an argument is serializable.(ttypeR(tclsR((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytcheckFs(t__name__t
__module__t__doc__RRtclassmethodR(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR;s		tMethodCallErrorcBseZdZRS(s*Raised when a L{MethodCall} command fails.(RRR(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRLst
MethodCallcBsWeZdZdeƒfdeƒfdeƒfgZdeƒfgZide6Z	RS(sÅCall a method on the object exposed by a L{MethodCallServerFactory}.

    The command arguments have the following semantics:

    - C{sequence}: An integer uniquely indentifying a the L{MethodCall}
      being issued. The name 'sequence' is a bit misleading because it's
      really a uuid, since its values in practice are not in sequential
      order, they are just random values. The name is kept just for backward
      compatibility.

    - C{method}: The name of the method to invoke on the remote object.

    - C{arguments}: A BPickled binary tuple of the form C{(args, kwargs)},
      where C{args} are the positional arguments to be passed to the method
      and C{kwargs} the keyword ones.
    tsequencetmethodt	argumentstresulttMETHOD_CALL_ERROR(
RRRR	RR"RtresponseRterrors(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRPstMethodCallChunkcBsKeZdZdeƒfdeƒfgZdeƒfgZide6ZRS(sSend a chunk of L{MethodCall} containing a portion of the arguments.

    When a the arguments of a L{MethodCall} are bigger than 64k, they get split
    in several L{MethodCallChunk}s that are buffered on the receiver side.

    The command arguments have the following semantics:

    - C{sequence}: The unique integer associated with the L{MethodCall} that
      this L{MethodCallChunk} is part of.

    - C{chunk}: A portion of the big BPickle C{arguments} string which is
      being split and buffered.
    R tchunkR#R$(	RRRR	RR"R%RR&(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR'ks

tMethodCallReceivercBsDeZdZd„Zejd„ƒZejd„ƒZd„Z	RS(s¼Expose methods of a local object over AMP.

    @param obj: The Python object to be exposed.
    @param methods: The list of the object's methods that can be called
         remotely.
    cCs,tj|ƒ||_||_i|_dS(N(R
t__init__t_objectt_methodst_pending_chunks(Rtobjtmethods((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR*Šs
		csΈjj|dƒ}|dk	r@|j|ƒdj|ƒ}nt|ƒ\}}|ˆjkrttd|ƒ‚ntˆj	|ƒ}‡fd†}d„}	t
|||Ž}
|
j|ƒ|
j|	ƒ|
S(sCall an object's method with the given arguments.

        If a connected client sends a L{MethodCall} for method C{foo_bar}, then
        the actual method C{foo_bar} of the object associated with the protocol
        will be called with the given C{args} and C{kwargs} and its return
        value delivered back to the client as response to the command.

        @param sequence: The integer that uniquely identifies the L{MethodCall}
            being received.
        @param method: The name of the object's method to call.
        @param arguments: A bpickle'd binary tuple of (args, kwargs) to be
           passed to the method. In case this L{MethodCall} has been preceded
           by one or more L{MethodCallChunk}s, C{arguments} is the last chunk
           of data.
        tsForbidden method '%s'csiˆj|ƒd6S(NR#(t
_check_result(R#(R(s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyt
handle_result®scSst|jƒ‚dS(N(Rtvalue(tfailure((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pythandle_failure±sN(
R-tpoptNonetappendtjoinRR,RtgetattrR+RtaddCallbackt
addErrback(RR R!R"tchunkstargstkwargstmethod_funcR2R5tdeferred((Rs5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytreceive_method_calls
	

cCs'|jj|gƒj|ƒi|d6S(s Receive a part of a multi-chunk L{MethodCall}.

        Add the received C{chunk} to the buffer of the L{MethodCall} identified
        by C{sequence}.
        R#(R-t
setdefaultR8(RR R(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytreceive_method_call_chunk¹scCs"tj|ƒstdƒ‚n|S(s¿Check that the C{result} we're about to return is serializable.

        @return: The C{result} itself if valid.
        @raises: L{MethodCallError} if C{result} is not serializable.
        sNon-serializable result(RRR(RR#((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR1Ãs(
RRRR*Rt	responderRBR'RDR1(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR)‚s
	)
tMethodCallSendercBs;eZdZdZeZd„Zd„Zgid„ZRS(sCall methods on a remote object over L{AMP} and return the result.

    @param protocol: A connected C{AMP} protocol.
    @param clock: An object implementing the C{IReactorTime} interface.

    @ivar timeout: A timeout for remote method class, see L{send_method_call}.
    i<cCs||_||_dS(N(t	_protocolt_clock(Rtprotocoltclock((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR*Ús	cshtƒ‰‡‡fd†}‡fd†}|jj|j|ƒ‰|jj||}|j|ƒˆS(sSend an L{AMP} command that will errback in case of a timeout.

        @return: A deferred resulting in the command's response (or failure) if
            the peer responds within C{self.timeout} seconds, or that errbacks
            with a L{MethodCallError} otherwise.
        cs+ˆjƒsdSˆjƒˆj|ƒdS(N(tactivetcanceltcallback(R%(RAtcall(s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pythandle_responseçs
csˆjtdƒƒdS(Nttimeout(terrbackR((RA(s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pythandle_timeoutïs(RRHt	callLaterRPRGt
callRemotetaddBoth(RtcommandR?RORRR#((RARNs5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyt_call_remote_with_timeoutÞs	
c
søt||fƒ}tƒj‰gtdt|ƒˆjƒD]}|||ˆj!^q:‰tƒ}tˆƒdkr²x:ˆd D]+}‡fd†}|j|ˆ|ƒƒq€Wn‡‡‡‡fd†}	|j|	ƒ|jd„ƒ|jdƒ|S(s—Send a L{MethodCall} command with the given arguments.

        If a response from the server is not received within C{self.timeout}
        seconds, the returned deferred will errback with a L{MethodCallError}.

        @param method: The name of the remote method to invoke.
        @param args: The positional arguments to pass to the remote method.
        @param kwargs: The keyword arguments to pass to the remote method.

        @return: A C{Deferred} firing with the return value of the method
            invoked on the remote object. If the remote method itself returns
            a deferred, we fire with the callback value of such deferred.
        iiiÿÿÿÿcs‡‡‡fd†}|S(NcsˆjjtdˆdˆƒS(NR R((RGRTR'(tx(RR R((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyt<lambda>s	((R R(t
send_chunk(R(R(R s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytcreate_send_chunkscs)ˆd}ˆjtdˆdˆd|ƒS(NiÿÿÿÿR R!R"(RWR(tignoredR((R R!R=R(s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytsend_last_chunks
cSs|dS(NR#((R%((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRY sN(
RRtinttxrangetlent_chunk_sizeRR;RMR7(
RR!R>R?R"tiR#R(R[R]((R RR=R!s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytsend_method_callùs9	

(	RRRRPRRaR*RWRc(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRFÎs		tMethodCallServerProtocolcBseZdZd„ZRS(sCReceive L{MethodCall} commands over the wire and send back results.cCs tj|dt||ƒƒdS(Ntlocator(RR*R)(RR.R/((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR*(s(RRRR*(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRd%stMethodCallClientProtocolcBseZdZdZd„ZRS(sASend L{MethodCall} commands over the wire using the AMP protocol.cCs&|jdk	r"|jj|ƒndS(s*Notify our factory that we're ready to go.N(tfactoryR7tclientConnectionMade(R((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytconnectionMade1sN(RRRR7RgRi(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRf,stRemoteObjectcBsVeZdZd„Zd„Zdd„Zdd„Zdd„Zd„Z	d„Z
RS(	sAn object able to transparently call methods on a remote object.

    Any method call on a L{RemoteObject} instance will return a L{Deferred}
    resulting in the return value of the same method call performed on
    the remote object exposed by the peer.
    cCs2d|_i|_||_|jj|jƒdS(sÅ
        @param factory: The L{MethodCallClientFactory} used for connecting to
            the other peer. Look there if you need to tweak the behavior of
            this L{RemoteObject}.
        N(R7t_sendert_pending_requestst_factorytnotifyOnConnectt_handle_connect(RRg((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR*?s			cs‡‡fd†}|S(s^Return a function sending a L{MethodCall} for the given C{method}.

        When the created function is called, it sends the an appropriate
        L{MethodCall} to the remote peer passing it the arguments and
        keyword arguments it was called with, and returning a L{Deferred}
        resulting in the L{MethodCall}'s response value.
        cs#tƒ}ˆjˆ|||ƒ|S(N(Rt_send_method_call(R>R?RA(RR!(s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRcRs	((RR!Rc((RR!s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyt__getattr__JscCs…|jjd|d|d|ƒ}|j|j|d|ƒ|j|j||||d|ƒ|jjdk	r|jjj	ƒndS(sASend a L{MethodCall} command, adding callbacks to handle retries.R!R>R?RNN(
RkRcR;t_handle_resultR<t_handle_failureRmtfake_connectionR7tflush(RR!R>R?RARNR#((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRpYs	
cCs*|dk	r|jƒn|j|ƒdS(s&Handles a successful C{send_method_call} result.

        @param response: The L{MethodCall} response.
        @param deferred: The deferred that was returned to the caller.
        @param call: If not C{None}, the scheduled timeout call associated with
            the given deferred.
        N(R7RLRM(RR#RARN((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRris
c
Csð|jtk}|jjtk}|s-|rs||jkrO|jj|ƒn|rb|jƒn|j|ƒdS|jj	rÓ|dkrÓttdƒƒ}	|jjj
|jj	|j|	|||d|ƒ}n||||f|j|<dS(s+Called when a L{MethodCall} command fails.

        If a failure is due to a connection error and if C{retry_on_reconnect}
        is C{True}, we will try to perform the requested L{MethodCall} again
        as soon as a new connection becomes available, giving up after the
        specified C{timeout}, if any.

        @param failure: The L{Failure} raised by the requested L{MethodCall}.
        @param name: The method name associated with the failed L{MethodCall}.
        @param args: The positional arguments of the failed L{MethodCall}.
        @param kwargs: The keyword arguments of the failed L{MethodCall}.
        @param deferred: The deferred that was returned to the caller.
        @param call: If not C{None}, the scheduled timeout call associated with
            the given deferred.
        NRPRA(RRRmtretryOnReconnecttFalseRlR6RLRQtretryTimeoutR7RRJRSRs(
RR4R!R>R?RARNtis_method_call_errort
dont_retryRP((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRsus 

	cCs5t||jjƒ|_|jjr1|jƒndS(saHandles a reconnection.

        @param protocol: The newly connected protocol instance.
        N(RFRmRJRkRvt_retry(RRI((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRo scCsg|jjƒ}|jjƒxD|rb|jƒ\}\}}}}|j||||d|ƒqWdS(s*Try to perform again requests that failed.RNN(RltcopytcleartpopitemRp(RtrequestsRAR!R>R?RN((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR{©s

	N(RRRR*RqR7RpRrRsRoR{(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRj7s		
*		tMethodCallServerFactorycBs&eZdZeZd„Zd„ZRS(s@Expose a Python object using L{MethodCall} commands over C{AMP}.cCs||_||_dS(s
        @param object: The object exposed by the L{MethodCallProtocol}s
            instances created by this factory.
        @param methods: A list of the names of the methods that remote peers
            are allowed to call on the C{object} that we publish.
        N(tobjectR/(RR.R/((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR*½s	cCs%|j|j|jƒ}||_|S(N(RIRR/Rg(RtaddrRI((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyt
buildProtocolÇs	(RRRRdRIR*Rƒ(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR€¸s	
tMethodCallClientFactorycBs€eZdZdZdZeZeZe	Z
dZdZ
d„Zd„Zd„Zd„Zd„Zd„Zd	„Zd
„ZRS(sÞ
    Factory for L{MethodCallClientProtocol}s exposing an object or connecting
    to L{MethodCall} servers.

    When used to connect, if the connection fails or is lost the factory
    will keep retrying to establish it.

    @ivar factor: The time factor by which the delay between two subsequent
        connection retries will increase.
    @ivar maxDelay: Maximum number of seconds between connection attempts.
    @ivar protocol: The factory used to build protocol instances.
    @ivar remote: The factory used to build remote object instances.
    @ivar retryOnReconnect: If C{True}, the remote object returned by the
        C{getRemoteObject} method will retry requests that failed, as a
        result of a lost connection, as soon as a new connection is available.
    @param retryTimeout: A timeout for retrying requests, if the remote object
        can't perform them again successfully within this number of seconds,
        they will errback with a L{MethodCallError}.
    g¨ô—›wãù?icCs4||_|j|_g|_g|_d|_dS(sö
        @param object: The object exposed by the L{MethodCallProtocol}s
            instances created by this factory.
        @param reactor: The reactor used by the created protocols
            to schedule notifications and timeouts.
        N(RJtinitialDelaytdelayt	_connectst	_requestsR7t_remote(RRJ((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR*ñs
			cCs9|jdk	rt|jƒStƒ}|jj|ƒ|S(s‹Get a L{RemoteObject} as soon as the connection is ready.

        @return: A C{Deferred} firing with a connected L{RemoteObject}.
        N(R‰R7RRRˆR8(RRA((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytgetRemoteObjectþs

	cCs|jj|ƒdS(sAInvoke the given C{callback} when a connection is re-established.N(R‡R8(RRM((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRn	scCs|jj|ƒdS(s,Remove the given C{callback} from listeners.N(R‡tremove(RRM((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pytdontNotifyOnConnect
scCsV|jdkr$|j|ƒ|_nx|jD]}||ƒq.W|j|jƒdS(s2Called when a newly built protocol gets connected.N(R‰R7tremoteR‡t_fire_requests(RRIRM((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRhs
cCs6tj|||ƒ|jdkr2|j|ƒndS(s0Try to connect again or errback pending request.N(RtclientConnectionFailedt_callIDR7RŽ(Rt	connectortreason((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRscCs |jƒtj||ƒ}|S(N(t
resetDelayRRƒ(RR‚RI((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRƒ%s
cCs5|j}g|_x|D]}|j|ƒqWdS(sY
        Fire all pending L{getRemoteObject} deferreds with the given C{result}.
        N(RˆRM(RR#RRA((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyRŽ*s
	
N(RRRtfactortmaxDelayRfRIRjRRwRvR7RxRtR*RŠRnRŒRhRRƒRŽ(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyR„Ís 	
						N(%RtuuidRttwisted.internet.deferRRRttwisted.internet.protocolRRttwisted.python.failureRttwisted.protocols.ampRRR	R
RRR
tlandscape.lib.bpickleRRRRt	ExceptionRRR'R)RRFRdRfRjR€R„(((s5/usr/lib/python2.7/dist-packages/landscape/lib/amp.pyt<module>.s"4LW

Youez - 2016 - github.com/yon3zu
LinuXploit