ó ±2öYc@sÁddlmZddlZddlmZddlmZddl m Z ddl m Z ddl jZddlZddlZddlZddlZddlZdefd„ƒYZdS( iÿÿÿÿ(tprint_functionN(tcommands(tLocator(tTunedAdminDBusException(tTunedExceptiontAdmincBsOeZeeeejd„Zd„Zd„Zd„Z d„Z d„Z d„Z d„Z d„Zd „Zd „Zd „Zd d „Zd d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d„Z$d „Z%d!„Z&d"„Z'RS(#cCsø||_||_||_||_t|ƒ|_ttjƒ|_ t j ƒ|_ d|_ t|_d|_d|_|jrôtjjtjtjtj|ƒ|_y|jjtj|jƒWqôtk rð}|j|ƒt|_qôXndS(Nt(t_dbust_debugt_asynct_timeoutRt_cmdtprofiles_locatortconststLOAD_DIRECTORIESt_profiles_locatort threadingtEventt_daemon_action_finishedt_daemon_action_profiletTruet_daemon_action_resultt_daemon_action_errstrtNonet _controllerttunedtadmintDBusControllertDBUS_BUStDBUS_INTERFACEt DBUS_OBJECTtset_signal_handlertDBUS_SIGNAL_PROFILE_CHANGEDt_signal_profile_changed_cbRt_errortFalse(tselftdbustdebugtasyncttimeoutte((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt__init__s$         ' cCst|dtjƒdS(Ntfile(tprinttsyststderr(R$tmessage((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyR"#scCs>|jjƒs:||_||_||_|jjƒndS(N(Rtis_setRRRtset(R$t profile_nametresultterrstr((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyR!&s    cCsiy)tjt|jjtjƒƒdƒWn9tk rK}|jtj kSt t fk rd}t SXt S(Ni(tostkilltintR t read_fileR tPID_FILEtOSErrorterrnotEPERMt ValueErrortIOErrorR#R(R$R)((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_tuned_is_running.s)cOs3|dks|dkrtSd}d}t}yt|d|ƒ}Wntk rc}t|_nXyt|d|ƒ}Wn5tk r²}|js³|j|d|ƒtSnX|jry)|jj|||Ž|jjƒ}Wqt k r}|j|ƒt|_qXn|js/|||Ž}n|S(NRt _action_dbus_t_action_s , action '%s' is not implemented( RR#tgetattrtAttributeErrorRR"Rt set_actiontrunR(R$t action_nametargstkwargstactiont action_dbustresR)((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyRI8s2     c Cs€tdƒxo|D]g}|ddk rf|ddkrft|jjd|ddd|dƒƒqtd|dƒqWdS(NsAvailable profiles:iRs- %sii(R,RR t align_str(R$t profile_namestprofile((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_print_profilesTs    /cCsky|jjƒ}Wn.tk rC}td„|jjƒƒ}nX|j|ƒ|jƒ|jjtƒS(NcSs |dfS(NR((RN((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pytas( Rt profiles2RtmaptprofilesROt_action_dbus_activetexitR(R$RMR)((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_list\s  cCs$|j|jjƒƒ|jƒtS(N(RORtget_known_names_summaryt_action_activeR(R$((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt _action_listfs cCs8|jjƒ}|dkr$d}n|jjtƒ|S(NR(Rtactive_profileRRUR(R$R2((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_dbus_get_active_profileks   cCs|jjƒ\}}|S(N(R tget_active_profile(R$R2tmanual((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_get_active_profilerscCsD|jjƒ\}}|dkr0|dk }n|r=tjStjS(N(R R\RR tACTIVE_PROFILE_MANUALtACTIVE_PROFILE_AUTO(R$RNR]((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_get_profile_modevs cCs€|dtkrjtdƒt|dƒtƒtdƒt|dƒtƒtdƒt|dƒtStd|ƒtSdS( Nis Profile name:isProfile summary:isProfile description:is,Unable to get information about profile '%s'(RR,R#(R$RNt profile_info((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_print_profile_info|s   RcCsC|dkr|jƒ}n|jj|j||jj|ƒƒƒS(NR(R[RRURcRb(R$RN((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_profile_info‹s cCs—|dkrcy*|jƒ}|dkr5tdƒtSWqctk r_}|jt|ƒƒtSXn|j||jj |t j t j gddgƒƒS(NRsNo current active profile.( R^RR,R#RR"tstrRcRtget_profile_attrsR tPROFILE_ATTR_SUMMARYtPROFILE_ATTR_DESCRIPTION(R$RNR)((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_profile_infos    cCs,|dkrtdƒtStd|ƒtS(NsNo current active profile.sCurrent active profile: %s(RR,R#R(R$R2((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_print_profile_nameœs   cCs|jj|j|jƒƒƒS(N(RRURjR[(R$((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyRT¤scCs|y|jƒ}Wn'tk r9}|jt|ƒƒtSX|dk ro|jƒ rotdƒtd|ƒtS|j |ƒS(NsKIt seems that tuned daemon is not running, preset profile is not activated.sPreset profile: %s( R^RR"ReR#RR?R,RRj(R$R2R)((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyRX§s cCstd|ƒdS(NsProfile selection mode: (R,(R$tmode((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_print_profile_mode³scCs[|jjƒ\}}|j|ƒ|dkrK|j|ƒ|jjtƒS|jjtƒS(NR(Rt profile_modeRlR"RUR#R(R$Rkterror((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_profile_mode¶s    cCsOy!|jƒ}|j|ƒtSWn'tk rJ}|jt|ƒƒtSXdS(N(RaRlRRR"ReR#(R$RkR)((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_profile_mode¾s  cCsP|r?|jjƒ rL|jjƒ rL|jdƒt}qLn |j|ƒ|S(NsCannot enable the tuning.(Rt is_runningtstartR"R#(R$trettmsg((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_profile_print_statusÇs     cCsœtjƒ|j|jkr=td|jƒ|jjtƒS|jjƒr˜|j |kr˜|j s…td|j ƒ|jjtƒS|jjt ƒSntS(Ns‰Operation timed out after waiting %d seconds(s), you may try to increase timeout by using --timeout command line option or using --async.sError changing profile: %s( ttimet _timestampR R,RRUR#RtisSetRRRR(R$R2((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_wait_profileÐs cCsÍt|ƒdkr|jƒSdj|ƒ}|dkrG|jjtƒS|jjƒ|jj|ƒ\}}|j s|| r˜|jj|j ||ƒƒSt j ƒ|_ |jj |j|ƒ|j ||ƒS(Nit R(tlenRVtjoinRRUR#Rtcleartswitch_profileR RuRvRwRDRy(R$RSR2RsRt((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_profileÜs   cCsRtdƒ|jjdddgƒ\}}|dkrDtdƒn tdƒdS(NsTrying to (re)start tuned...tserviceRtrestartis#Tuned (re)started, changes applied.sQTuned (re)start failed, you need to (re)start tuned by hand for changes to apply.(R,R texecute(R$RsRt((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_restart_tunedës  !  cCs||jjƒkrty%|jj||ƒ|jƒtSWq‰tk rp}|jt|ƒƒ|jdƒt SXn|jd|ƒt SdS(NsUnable to switch profile.s%Requested profile '%s' doesn't exist.( Rtget_known_namesR tsave_active_profileRƒRRR"ReR#(R$R2R]R)((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt _set_profileós  cCsKt|ƒdkr|jƒSdj|ƒ}|dkr;tS|j|tƒS(NiRzR(R{RYR|R#R†R(R$RSR2((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_profiles   cCs’|jjƒ}|jjƒ|jjƒ\}}|jsA| r]|jj|j||ƒƒStjƒ|_ |jj |j |ƒ|j||ƒS(N( Rtrecommend_profileRR}t auto_profileR RURuRvRwRDRy(R$R2RsRt((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_auto_profile s cCs|jjƒ}|j|tƒS(N(R RˆR†R#(R$R2((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_auto_profilescCs#t|jjƒƒ|jjtƒS(N(R,RRˆRUR(R$((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_recommend_profilescCst|jjƒƒtS(N(R,R RˆR(R$((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_recommend_profilescCs—|r|jjƒ}n|jjƒ}|r:tdƒn<tdƒtdƒtdƒtdƒtdƒtdƒtdtjƒ|jj|ƒS( NsHVerfication succeeded, current system settings match the preset profile.sLVerification failed, current system settings differ from the preset profile.s=You can mostly fix this by restarting the Tuned daemon, e.g.:s systemctl restart tunedtors service tuned restartsNSometimes (if some plugins like bootloader are used) a reboot may be required.s&See tuned log file ('%s') for details.(Rtverify_profile_ignore_missingtverify_profileR,R tLOG_FILERU(R$tignore_missingRs((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_verify_profile s       cCstdƒtS(Ns Not supported in no_daemon mode.(R,R#(R$R’((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_verify_profile1s cCs5|jjƒ}|s%|jdƒn|jj|ƒS(NsCannot disable active profile.(RtoffR"RU(R$Rs((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt_action_dbus_off5scCstdƒtS(Ns Not supported in no_daemon mode.(R,R#(R$((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyt _action_off;s ((t__name__t __module__RR#R t ADMIN_TIMEOUTR*R"R!R?RIRORVRYR[R^RaRcRdRiRjRTRXRlRoRpRuRyRRƒR†R‡RŠR‹RŒRR“R”R–R—(((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyRsD                        (t __future__Rt tuned.adminRttuned.utils.commandsRttuned.profilesRR t exceptionsRttuned.exceptionsRt tuned.constsR R5R-R;RvRtobjectR(((s5/usr/lib/python2.7/site-packages/tuned/admin/admin.pyts