MINI MINI MANI MO

Path : /usr/lib/python2.7/site-packages/tuned/daemon/
File Upload :
Current File : //usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyo

ó
©=[c@s´ddlZddlZddlZddlZddlmZddlmZddl	j
Z
ddlmZddlm
Z
ddlZejjƒZdefd„ƒYZdS(iÿÿÿÿN(tTunedException(tInvalidProfileException(tcommands(texportstDaemoncBsËeZdddd„Zd„Zd„Zed„Zed„ƒZ	ed„ƒZ
ed„ƒZd„Zd„Z
d	„Zd
„Zd„Zd„Zd
„Zd„Zd„Zd„Zed„ZRS(cCs%tjdƒtj|_ttjƒ|_ttjƒ|_	tj
|_t|_
|dk	rô|jtjtjƒ|_t|jtjtjƒƒ|_t|jtjtjƒƒ|_	|jtjtj
ƒ|_|jtjtjƒ|_
n||_|jdkr!ttjƒ|_n|j	dkr<t|_n!|j	|jkr]|j|_	n|j	|j|_tjd|jƒ|jrÁtjdƒtjd|j|j|jfƒn||_||_|jƒtƒ|_y|j |ƒWn$t!k
r }tj"d|ƒnXdS(Nsinitializing daemonis$using sleep interval of %d second(s)s8dynamic tuning is enabled (can be overridden by plugins)sFusing update interval of %d second(s) (%d times of the sleep interval)s:Cannot set initial profile. No tunings will be enabled: %s(#tlogtdebugtconststCFG_DEF_DAEMONt_daemontinttCFG_DEF_SLEEP_INTERVALt_sleep_intervaltCFG_DEF_UPDATE_INTERVALt_update_intervaltCFG_DEF_DYNAMIC_TUNINGt_dynamic_tuningtTruet_recommend_commandtNonetget_boolt
CFG_DAEMONtgettCFG_SLEEP_INTERVALtCFG_UPDATE_INTERVALtCFG_DYNAMIC_TUNINGtCFG_RECOMMEND_COMMANDtCFG_DEF_RECOMMEND_COMMANDt_applicationtFalset
_sleep_cyclestinfot
_unit_managert_profile_loadert
_init_threadsRt_cmdt
_init_profileRterror(tselftunit_managertprofile_loadert
profile_namestconfigtapplicationte((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyt__init__s@
	!!		
'		
cCsVd|_tjƒ|_tjƒ|_tjƒ|_|jjƒtjƒ|_dS(N(	Rt_threadt	threadingtEventt
_terminatet_terminate_profile_switcht	_not_usedtsett_profile_applied(R&((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR"3s	
cCs…t}|dkrC|jƒ\}}|dkr_tjdƒq_n|dkr_tjdƒnd|_d|_|j||ƒdS(NsINo profile is preset, running in manual mode. No profile will be enabled.tsNo profile will be enabled.(RRt_get_startup_profileRRt_profilet_manualtset_profile(R&R)tmanual((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR$=s		cCs=|jƒr*t|j|tdƒƒ‚n|dksB|dkrWd|_||_n´|jƒ}xH|D]@}||jj	j
ƒkrjt|j|td|ƒƒ‚qjqjWy"|jj|ƒ|_||_Wn8t
k
r
}t|j|td||fƒƒ‚nX|r9|dkr&d}n|j||ƒndS(Ns/Cannot set profile while the daemon is running.R6s%Requested profile '%s' doesn't exist.sCannot load profile(s) '%s': %s(t
is_runningRt_notify_profile_changedRRR8R9tsplitR(tprofile_locatortget_known_namesR!tloadRt_save_active_profile(R&R)R;tsave_instantlytprofile_listtprofileR,((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR:Ks(	
	
)	cCs|jS(N(R8(R&((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyREdscCs|jS(N(R9(R&((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR;hscCs|jS(N(R!(R&((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR(lscCsG|jdk	rC|jjdk	rC|jjjtj|||ƒn|S(N(RRt_dbus_exportertsend_signalRtDBUS_SIGNAL_PROFILE_CHANGED(R&R)tresultterrstr((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR=rs!"cCsˆ|jjddgddgƒ\}}|dkr7tS|d dkrKtS|jjddgddgƒ\}}tjd|ƒdkS(	Nt	systemctlsis-system-runningt	no_errorsiitstoppings	list-jobss0\b(shutdown|reboot|halt|poweroff)\.target.*start(R#texecuteRtretsearchR(R&tretcodetout((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyt_full_rollback_requiredws''cCs|jdkrtdƒ‚n|jj|jjƒ|j|jj|jƒ|jj	ƒ|j
jƒtj
d|jjƒ|jr”tjƒn|j|jjtdƒ|jrF|j}x„|jj|j|jƒsB|jrÂ|d8}|dkr?|j}tjdƒ|jjƒtjdƒ|jjƒq?qÂqÂWn|j
jƒd}x6|jj|j|jƒr‘|dkr‘|d7}q\W|jjƒrªt}n5t }|j!ƒrÒtj
d	ƒt}n
tj
d
ƒ|jrû|jj"|ƒn|jj#ƒdS(Ns2Cannot start the daemon without setting a profile.s'static tuning from profile '%s' appliedtOKiisupdating monitorssperforming tuningsis+terminating Tuned, rolling back all changess1terminating Tuned due to system shutdown / reboot($R8RRR tcreatetunitsRBtnameR9tstart_tuningR5R4RRR	RtstartR=RRR#twaitR1RRRtupdate_monitorst
update_tuningtclearR3R2tis_setRRStstop_tuningtdestroy_all(R&t
_sleep_cnttit
full_rollback((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyt_thread_code€sF

	
			
	



+	
	
	cCsDy|jj||ƒWn&tk
r?}tjt|ƒƒnXdS(N(R#tsave_active_profileRRR%tstr(R&R)R;R,((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyRB¸scCs;tjdƒ|jjd|jƒ}tjd|ƒ|S(NsWRunning in automatic mode, checking what profile is recommended for your configuration.t	hardcodedsUsing '%s' profile(RRR#trecommend_profileR(R&RE((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyt_get_recommended_profile¾s
cCsO|jjƒ\}}|dkr0|dk	}n|sE|jƒ}n||fS(N(R#tget_active_profileRRi(R&RER;((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR7ÄscCs
|jdk	S(N(R8R(R&((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyt
is_enabledÌscCs|jdk	o|jjƒS(N(R.Rtis_alive(R&((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyR<ÏscCs€|jƒrtS|jdkr#tStjdƒ|jjƒtj	d|j
ƒ|_|jj
ƒ|jj
ƒ|jjƒtS(Nsstarting tuningttarget(R<RR8RRRR3R4R/tThreadRdR.R2R]R1RYR(R&((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyRYÒs




cCs¤|jƒstjdƒtS|jdkr=tjdƒtS|jjƒs]tjdƒtS|jj	ƒtj
d|jjƒ|jj
|ƒ}|jjƒ|S(Nstuned is not runningsno profile is setsprofile is not appliedsverifying profile(s): %s(R<RR%RR8RR5R^R3R]RRWR t
verify_tuningR4(R&tignore_missingtret((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pytverify_profileás




cCsZ|jƒstStjdƒ|r3|jjƒn|jjƒ|jjƒd|_t
S(Nsstopping tuning(R<RRRR2R4R1R.tjoinRR(R&tprofile_switch((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pytstop÷s


	N(t__name__t
__module__RR-R"R$RR:tpropertyRER;R(R=RSRdRBRiR7RkR<RYRrRu(((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyRs$#	
					8							(tosterrnoR/t
tuned.logsttunedttuned.exceptionsRttuned.profiles.exceptionsRttuned.constsRttuned.utils.commandsRRROtlogsRRtobjectR(((s7/usr/lib/python2.7/site-packages/tuned/daemon/daemon.pyt<module>s

OHA YOOOO