Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/package/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyc

ó
ÍÿŠTc@s*ddlZddlZddlZddlmZmZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZddlmZmZddlmZmZdd	lmZd
efd„ƒYZdefd
„ƒYZdefd„ƒYZdefd„ƒYZdd„ZdS(iÿÿÿÿN(tsucceedtDeferred(t	lock_patht	LockError(tlog_failure(tLSB_RELEASE_FILENAMEtparse_lsb_release(tLandscapeReactor(t
Configurationtinit_logging(tPackageStoretInvalidHashIdDb(tRemoteBrokerConnectortPackageTaskErrorcBseZdZRS(s6Raised when a task hasn't been successfully completed.(t__name__t
__module__t__doc__(((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyR
stPackageTaskHandlerConfigurationcBsYeZdZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZRS(s5Specialized configuration for L{PackageTaskHandler}s.cCstjj|jdƒS(s&Get the path to the package directory.tpackage(tostpathtjoint	data_path(tself((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytpackage_directoryscCstjj|jdƒS(s8Get the path to the SQlite file for the L{PackageStore}.tdatabase(RRRR(R((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytstore_filenamescCstjj|jdƒS(s?Get the path to the directory holding the stock hash-id stores.shash-id(RRRR(R((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pythash_id_directory!scCstjj|jdƒS(s&Get the path to the update-stamp file.supdate-stamp(RRRR(R((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytupdate_stamp_filename&scCstjj|jdƒS(shGet the path to the stamp marking when the last time we checked for
        changes in the packages was.t detect_package_changes_timestamp(RRRR(R((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytdetect_package_changes_stamp+s(	RRRtpropertyRRRRR(((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyRstLazyRemoteBrokercBs eZdZd„Zd„ZRS(sWrapper class around L{RemoteBroker} providing lazy initialization.

    This class is a wrapper around a regular L{RemoteBroker}. It connects to
    the remote broker object only when one of its attributes is first accessed.

    @param connector: The L{RemoteBrokerConnector} which will be used
        to connect to the broker.

    @note: This behaviour is needed in particular by the ReleaseUpgrader and
        the PackageChanger, because if the they connect early and the
        landscape-client package gets upgraded while they run, they will lose
        the connection and will not be able to reconnect for a potentially long
        window of time (till the new landscape-client package version is fully
        configured and the service is started again).
    cCs||_d|_dS(N(t
_connectortNonet_remote(Rt	connector((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyt__init__Cs	cs/ˆjrtˆjˆƒS‡‡fd†}|S(Ncs4‡‡‡‡fd†}ˆjjƒ}|j|ƒS(Ncs"|ˆ_tˆjˆƒˆˆŽS(N(R#tgetattr(tremote(Rtargstkwargstmethod(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytgot_connectionNs	(R!tconnecttaddCallback(R(R)R+tresult(RR*(R(R)sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytwrapperLs(R#R&(RR*R/((RR*sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyt__getattr__Gs		(RRRR%R0(((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyR 2s	tPackageTaskHandlercBs‰eZeZdZeZeZdZ	d„Z
d„Zd„Zdd„Zd„Zd„Zed„ƒZd	„Zd
„Zd„ZRS(
tdefaults*/var/lib/apt/periodic/update-success-stampcCs:||_||_||_||_d|_d|_dS(Ni(t_storet_facadet_brokert_configt_countR"t_session_id(Rt
package_storetpackage_facadet
remote_brokertconfig((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyR%ds					cCs
|jƒS(N(thandle_tasks(R((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytrunlscCs
|jdƒS(s¼Handle the tasks in the queue.

        The tasks will be handed over one by one to L{handle_task} until the
        queue is empty or a task fails.

        @see: L{handle_tasks}
        N(t_handle_next_taskR"(R((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyR=oscCsŠ|dk	r(|jƒ|jd7_n|jj|jƒ}|r||j|ƒ}|j|jd|ƒ|j	|j
ƒ|StdƒSdS(s@Pick the next task from the queue and pass it to C{handle_task}.it	last_taskN(R"tremoveR7R3t
get_next_taskt
queue_namethandle_taskR-R?t
addErrbackt_handle_task_failureR(RR.R@ttask((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyR?ys
cCs|jtƒdS(s@Gracefully handle a L{PackageTaskError} and stop handling tasks.N(ttrapR
(Rtfailure((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyRFŽscCs
tdƒS(sHandle a single task.

        Sub-classes must override this method in order to trigger task-specific
        actions.

        This method must return a L{Deferred} firing the task result. If the
        deferred is successful the task will be removed from the queue and the
        next one will be picked. If the task can't be completed, this method
        must raise a L{PackageTaskError}, in this case the handler will stop
        processing tasks and the failed task won't be removed from the queue.
        N(RR"(RRG((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyRD’scCs|jS(sX
        Return the number of tasks that have been successfully handled so far.
        (R7(R((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pythandled_tasks_count scs,‡fd†}ˆjƒ}|j|ƒ|S(sS
        Attach the appropriate pre-canned hash=>id database to our store.
        csq|dkrdStjj|ƒs&dSyˆjj|ƒWn0tk
rltjd|ƒtj	|ƒdSXdS(NsInvalid hash=>id database %s(
R"RRtexistsR3tadd_hash_id_dbRtloggingtwarningRA(thash_id_db_filename(R(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytuse_it¬s
	
(t_determine_hash_id_db_filenameR-(RRPR.((RsA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytuse_hash_id_db§s
cs/‡fd†}ˆjjƒ}|j|ƒ|S(s§Build up the filename of the hash=>id database to use.

        @return: a deferred resulting in the filename to use or C{None}
            in case of errors.
        csód}|dkr'tj|dƒdSytˆjƒ}Wn+tk
rg}tj|t|ƒƒdSXy|d}Wn*tk
r¢tj|dˆjƒdSXˆjj	ƒ}|sÍtj|dƒdSt
jjˆj
jd|||fƒS(Ns5Couldn't determine which hash=>id database to use: %ssserver UUID not availables	code-namesmissing code-name key in %ssunknown dpkg architectures%s_%s_%s(R"RMRNRtlsb_release_filenametIOErrortstrtKeyErrorR4tget_archRRRR6R(tserver_uuidRNtlsb_release_infoterrortcodenametarch(R(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytgot_server_uuidÍs*

(R5tget_server_uuidR-(RR]R.((RsA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyRQÆs
cs/‡fd†}ˆjjƒ}|j|ƒ|S(Ncs
|ˆ_|S(N(R8(t
session_id(R(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytgot_session_idòs	(R5tget_session_idR-(RR`R.((RsA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyRaðs
N(RRRtconfig_factoryRCRRSR
tpackage_store_classtupdate_notifier_stampR%R>R=R"R?RFRDRRJRRRQRa(((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyR1Xs			
				*c
sˆdkrtƒ‰n|jƒ}|j|ƒx<|j|jgD](}tjj|ƒsDtj	|ƒqDqDW|j
}tjj|j|dƒ}yt|ƒWn6t
k
rÛ|jrÈtƒ‚ntd|ƒ‚nXtjd|jƒ}t|djd„|Dƒƒƒtjdƒ|j|jƒ}ddlm}	|	ƒ}
‡‡fd	†‰‡fd
†}tˆ|dtƒ‰tˆƒ}|||
||ƒ‰tƒ‰ˆj‡fd†ƒˆj‡fd
†ƒˆj|ƒˆj‡fd†ƒˆj ƒˆS(Ns.locks$error: package %s is already runnings[A-Z][a-z]+t-css|]}|jƒVqdS(N(tlower(t.0tword((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pys	<genexpr>siiÿÿÿÿ(t	AptFacadecs!ˆjƒˆjdˆjƒdS(Ni(t
disconnectt
call_latertstop((R$treactor(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytfinish s
cst|ƒˆƒdS(N(R(RI(Rn(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyt	got_error$s
tretry_on_reconnectcs
ˆjƒS(N(R>(tx(thandler(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyt<lambda>,scsˆƒS(N((Rq(Rn(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyRs-scs
ˆjdƒS(N(tcallbackR"((R.(sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyRs/s(!R"RRbtloadRRRRtisdirtmkdirRCRRRtquiett
SystemExittretfindallRR	tumaskRcRtlandscape.package.facadeRiRtTrueR RR-REtcall_when_runningR>(
tclsR(RmR<t	directorytprogram_namet
lock_filenametwordsR9RiR:RoR'((RmR.R$RrRnsA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pytrun_task_handlerûsF
	

	 
		

( RRzRMttwisted.internet.deferRRtlandscape.lib.lockRRtlandscape.lib.logRtlandscape.lib.lsb_releaseRRtlandscape.reactorRtlandscape.deploymentRR	tlandscape.package.storeR
Rtlandscape.broker.ampRt	ExceptionR
RtobjectR R1R"R…(((sA/usr/lib/python2.7/dist-packages/landscape/package/taskhandler.pyt<module>s&£