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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/landscape/reactor.pyc
ó
}9Rc@s*dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZde
fd„ƒYZd	e
fd
„ƒYZdefd„ƒYZd
efd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(sB
Extend the regular Twisted reactor with event-handling features.
iÿÿÿÿN(tFailure(tConnectError(t
deferToThread(t
format_objectt	InvalidIDcBseZdZRS(s=Raised when an invalid ID is used with reactor.cancel_call().(t__name__t
__module__t__doc__(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRst
CallHookErrorcBseZdZRS(s-Raised when hooking on a reactor incorrectly.(RRR(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRstEventIDcBseZdZd„ZRS(sßUnique identifier for an event handler.

    @param event_type: Name of the event type handled by the handler.
    @param pair: Binary tuple C{(handler, priority)} holding the handler
        function and its priority.
    cCs||_||_dS(N(t_event_typet_pair(tselft
event_typetpair((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt__init__ s	(RRRR(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR	stEventHandlingReactorMixincBs5eZdZd„Zdd„Zd„Zd„ZRS(s„Fire events identified by strings and register handlers for them.

    Note that event handlers are executed synchronously when the C{fire} method
    is called, so unit-tests can generally exercise events without needing to
    run the real Twisted reactor (except of course if the event handlers
    themselves contain asynchronous calls that need the Twisted reactor
    running).
    cCs tt|ƒjƒi|_dS(N(tsuperRRt_event_handlers(R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR/sicCsN||f}|jj|gƒ}|j|ƒ|jdd„ƒt||ƒS(sÕRegister an event handler.

        The handler will be invoked every time an event of the given type
        is fired (there's no need to re-register the handler after the
        event is fired).

        @param event_type: The name of the event type to handle.
        @param handler: The function handling the given event type.
        @param priority: The priority of the given handler function.

        @return: The L{EventID} of the registered handler.
        tkeycSs|dS(Ni((R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt<lambda>Ds(Rt
setdefaulttappendtsortR	(RR
thandlertpriorityRthandlers((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pytcall_on3s


cOs÷tjd|ƒg}t|jj|dƒƒ}x¯|D]§\}}y6tjdt|ƒ||ƒ|j|||ŽƒWq8tk
r¹tjdt|ƒ|||ƒ|j	ƒ‚q8tjdt|ƒ|||ƒq8Xq8Wtjd|ƒ|S(scFire an event of a given type.

        Call all handlers registered for the given C{event_type}, in order
        of priority.

        @param event_type: The name of the event type to fire.
        @param args: Positional arguments to pass to the registered handlers.
        @param kwargs: Keyword arguments to pass to the registered handlers.
        sStarted firing %s.s#Calling %s for %s with priority %d.sTKeyboard interrupt while running event handler %s for event type %r with args %r %r.sAError running event handler %s for event type %r with args %r %r.sFinished firing %s.((
tloggingtdebugtlistRtgetRRtKeyboardInterruptt	exceptiontstop(RR
targstkwargstresultsRRR((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pytfireHs(
	
		

	cCsCt|ƒtkr/|j|jj|jƒntd|ƒ‚dS(sfUnregister an event handler.

        @param id: the L{EventID} of the handler to unregister.
        s&EventID instance expected, received %rN(ttypeR	RR
tremoveRR(Rtid((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pytcancel_callls(RRRRRR&R*(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR%s
		$t	ReactorIDcBseZd„ZRS(cCs
||_dS(N(t_timeout(Rttimeout((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRys(RRR(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR+wstLandscapeReactorcBsƒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„ZRS(sWrap and add functionalities to the Twisted reactor.

    This is essentially a facade around the L{twisted.internet.reactor} and
    will delegate to it for mostly everything except event handling features
    which are implemented using L{EventHandlingReactorMixin}.
    cCs_ddlm}ddlm}||_||_|jƒ|j|_tt	|ƒj
ƒdS(Niÿÿÿÿ(treactor(tLoopingCall(ttwisted.internetR/ttwisted.internet.taskR0t_LoopingCallt_reactort_cleanuptcallFromThreadRR.R(RR/R0((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR…s		
cCs
tjƒS(s5Get current time.

        @see L{time.time}
        (ttime(R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR7ŽscOs|jj||ŽS(s°Call a function later.

        Simply call C{callLater(*args, **kwargs)} and return its result.

        @see: L{twisted.internet.interfaces.IReactorTime.callLater}.

        (R4t	callLater(RR#R$((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt
call_later•scOs,|j|||Ž}|j|dtƒ|S(s±Call a function repeatedly.

        Create a new L{twisted.internet.task.LoopingCall} object and
        start it.

        @return: the created C{LoopingCall} object.
        tnow(R3tstarttFalse(RtsecondstfR#R$tlc((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt
call_everyŸscCsXt|tƒrtj||ƒSt||jƒr;|jƒS|jƒrT|jƒndS(sCancel a scheduled function or event handler.

        @param id: The function call or handler to remove. It can be an
            L{EventID}, a L{LoopingCall} or a C{IDelayedCall}, as returned
            by L{call_on}, L{call_every} and L{call_later} respectively.
        N(t
isinstanceR	RR*R3R"tactivetcancel(RR)((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR*«s
cCs|jj|ƒdS(sASchedule a function to be called when the reactor starts running.N(R4tcallWhenRunning(RR>((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pytcall_when_running¹scOs|jj|||ŽdS(s1Cause a function to be executed by the reactor thread.

        @param f: The callable object to execute.
        @param args: The arguments to call it with.
        @param kwargs: The keyword arguments to call it with.

        @see: L{twisted.internet.interfaces.IReactorThreads.callFromThread}
        N(R4R6(RR>R#R$((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pytcall_in_main½s	c	sN‡fd†}‡fd†}t|||Ž}|j|ƒ|j|ƒdS(s
        Execute a callable object in a new separate thread.

        @param callback: A function to call in case C{f} was successful, it
            will be passed the return value of C{f}.
        @param errback: A function to call in case C{f} raised an exception,
            it will be pass a C{(type, value, traceback)} tuple giving
            information about the raised exception (see L{sys.exc_info}).

        @note: Both C{callback} and C{errback} will be executed in the
            the parent thread.
        csˆrˆ|ƒSdS(N((tresult(tcallback(s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt
on_successÕscsF|j|j|jf}ˆr+ˆ|Œntj|dd|ƒdS(Nitexc_info(R'tvaluettbRterror(tfailureRJ(terrback(s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt
on_failureÙs
N(RtaddCallbackt
addErrback(	RRHROR>R#R$RIRPtdeferred((RHROs5/usr/lib/python2.7/dist-packages/landscape/reactor.pytcall_in_threadÈs


cCs|jj||dtƒS(s!Start listening on a Unix socket.twantPID(R4t
listenUNIXtTrue(Rtsockettfactory((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pytlisten_unixäscCs|jj||ƒS(sConnect to a Unix socket.(R4tconnectUNIX(RRXRY((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pytconnect_unixèscCs+|jdƒ|jjƒ|jdƒdS(s2Start the reactor, a C{"run"} event will be fired.trunR"N(R&R4R](R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR]ìs

cCs|jjƒ|jƒdS(s2Stop the reactor, a C{"stop"} event will be fired.N(R4R"R5(R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR"ós
cCs7x0|jjƒD]}|jƒr|jƒqqWdS(N(R4tgetDelayedCallsRBRC(Rtcall((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR5øs(RRRRR7R9R@R*RERFRTRZR\R]R"R5(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR.}s				
									t
FakeReactorIDcBseZd„ZRS(cCst|_||_dS(N(RWRBt_data(Rtdata((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRs	(RRR(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR`stFakeReactorcBs­eZdZiZd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd	„Zd
„Z
d„Zd„Zd
„Zd„Zd„Zd„Zd„ZRS(swA fake reactor with the same API of L{LandscapeReactor}.

    This reactor emulates the asychronous interface of L{LandscapeReactor}, but
    implementing it in a synchronous way, for easier unit-testing.

    Note that the C{listen_unix} method is *not* emulated, but rather inherited
    blindly from L{UnixReactorMixin}, this means that there's no way to control
    it in a synchronous way (see the docstring of the mixin). A better approach
    would be to fake the AMP transport (i.e. fake the twisted abstractions
    around Unix sockets), and implement a fake version C{listen_unix}, but this
    hasn't been done yet.
    cCsTtt|ƒjƒd|_g|_i|_g|_ddlm}||_	dS(Niiÿÿÿÿ(R/(
RRcRt
_current_timet_callsthostst_threaded_callbacksR1R/R4(RR/((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRs				cCs
t|jƒS(N(tfloatRd(R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR7%scOs<|j|}||||f}tj|j|ƒt|ƒS(N(Rdtbisecttinsort_leftReR`(RR=R>R#R$tscheduled_timeR_((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR9(s
cs7‡‡‡‡‡‡‡fd†‰ˆjˆˆƒ‰ˆS(NcsSˆjˆˆƒjˆ_yˆˆˆŽWn#ˆjrHˆjˆƒn‚nXdS(N(R9RaRBR*((R>R=R$RR#R_tfake(s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRl0s	(R9(RR=R>R#R$((RlR>R=RR#R_R$s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR@.s!cCs`t|ƒtkrF|j|jkr:|jj|jƒnt|_ntt|ƒj	|ƒdS(N(
R'R`RaReR(R<RBRRcR*(RR)((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR*>s
cCs|jd|ƒdS(Ni(R9(RR>((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyREFscs#|jj‡‡‡fd†ƒdS(s5Schedule a function for execution in the main thread.cs
ˆˆˆŽS(N(((R$R#R>(s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRLsN(RgR(RR>R#R$((R$R#R>s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRFJscOs'|j|||||ƒ|jƒdS(ssEmulate L{LandscapeReactor.call_in_thread} without spawning threads.

        Note that running threaded callbacks here doesn't reflect reality,
        since they're usually run while the main reactor loop is active. At
        the same time, this is convenient as it means we don't need to run
        the the real Twisted reactor with to test actions performed on
        completion of specific events (e.g. L{MessageExchange.exchange} uses
        call_in_thread to run the HTTP request in a separate thread, because
        we use libcurl which is blocking). IOW, it's easier to test things
        synchronously.
        N(t
_in_threadt_run_threaded_callbacks(RRHROR>R#R$((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRTNscs3dtf‡‡fd†ƒY}|ˆjˆ<|ƒS(NtFakePortcseZ‡‡fd†ZRS(csˆjjˆƒdS(N(t
_socket_pathstpop(toself(tsocket_pathR(s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt
stopListeningas(RRRt((RsR(s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRo_s(tobjectRp(RRsRYRo((RsRs5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRZ]s
cCss|jj|ƒ}ddlm}|rD|||ƒ}|jƒn+tƒ}ttdƒƒ}|j||ƒ|S(Niÿÿÿÿ(t
FakeConnectorsNo such file or directory(	RpRtlandscape.lib.tests.test_ampRvtconnectRuRRtclientConnectionFailed(RtpathRYtserverRvt	connectorRN((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR\gs
	cCsO|jdƒt|_x%|jr=|j|jddƒqW|jdƒdS(sAContinuously advance this reactor until reactor.stop() is called.R]iR"N(R&RWt_runningtadvanceRe(R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR]ss

	cCs
t|_dS(N(R<R}(R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR"{scCsµxŸ|jr¡|jdd|j|kr¡|jjdƒ}||d|j8}|d|_y|d|d|dŽWqtk
r}tj|ƒqXqW|j|7_dS(sHAdvance this reactor C{seconds} into the future.

        This method is not part of the L{LandscapeReactor} API and is specific
        to L{FakeReactor}. It's meant to be used only in unit tests for
        advancing time and triggering the relevant scheduled calls (see
        also C{call_later} and C{call_every}).
        iiiiN(ReRdRqt	ExceptionRR!(RR=R_te((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyR~~s
c	CsŠy|||Ž}WnWtk
rl}tjƒ}|dkrY|jtj|d|ƒq†|j||ŒnX|r†|j||ƒndS(NRJ(RtsysRJtNoneRFRRM(	RRHROR>R#R$RGR€RJ((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRm–scCsNxG|jrIy|jjdƒƒWqtk
rE}tj|ƒqXqWdS(Ni(RgRqRRR!(RR€((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRn£s
cCs"|jd|jƒ}||_dS(Ngà?(R@Rnt_run_threaded_callbacks_id(RR)((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt_hook_threaded_callbacksªscCs|j|jƒdS(N(R*Rƒ(R((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt_unhook_threaded_callbacks®s(RRRRpRR7R9R@R*RERFRTRZR\R]R"R~RmRnR„R…(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyRcs&									
					
		(RR7RRRittwisted.python.failureRttwisted.internet.errorRttwisted.internet.threadsRt
landscape.logRRRRRuR	RR+R.R`Rc(((s5/usr/lib/python2.7/dist-packages/landscape/reactor.pyt<module>s 
Rƒ

Youez - 2016 - github.com/yon3zu
LinuXploit