HEX
Server: LiteSpeed
System: Linux w5304130.sdnsbox.com 4.18.0-425.3.1.lve.el8.x86_64 #1 SMP Tue Nov 22 22:59:23 EST 2022 x86_64
User: makefitmeserver (1001)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/tuned/daemon/__pycache__/controller.cpython-36.opt-1.pyc
3

]�b?"�@s�ddlmZddlZddlZddlmZddlZddljZddlm	Z	dgZ
ejj�Z
Gdd�de�ZGdd�dejjj�ZdS)	�)�exportsN)�TunedException)�commands�
Controllerc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TimerStorecCst�|_tj�|_dS)N)�dict�_timers�	threadingZLock�_timers_lock)�self�r� /usr/lib/python3.6/controller.py�__init__szTimerStore.__init__c
Cs |j�||j|<WdQRXdS)N)r
r)r�token�timerrrr
�store_timerszTimerStore.store_timercCsB|j�2y|j|}|j�|j|=WnYnXWdQRXdS)N)r
r�cancel)rrrrrr
�
drop_timers
zTimerStore.drop_timerc	Cs<|j�,x|jj�D]}|j�qW|jj�WdQRXdS)N)r
r�valuesr�clear)rrrrr
�
cancel_allszTimerStore.cancel_allN)�__name__�
__module__�__qualname__rrrrrrrr
r
s	rcs eZdZdZ�fdd�Zdd�Zdd�Zejd�d	d
��Z	dd�Z
ejd
d�dEdd��Zejdd�dFdd��Z
ejdd�dGdd��Zejdd�dHdd��Zejdd�dIdd��Zdd�Zejdd�dJdd ��Zejdd�dKd!d"��Zejdd�dLd#d$��Zejdd%�dMd&d'��Zejdd�dNd(d)��Zejdd�dOd*d+��Zejdd�dPd,d-��Zejdd.�dQd/d0��Zejdd1�dRd2d3��Zejdd4�dSd5d6��Zejdd�dTd7d8��Zejdd�dUd9d:��Zejdd�dVd;d<��Zejdd=�dWd>d?��Zejdd�dXd@dA��Z ejddB�dYdCdD��Z!�Z"S)Zrz�
	Controller's purpose is to keep the program running, start/stop the tuning,
	and export the controller interface (currently only over D-Bus).
	cs8tt|�j�||_||_tj�|_t�|_	t
�|_dS)N)�superrr�_daemon�_global_configr	ZEvent�
_terminater�_cmdr�_timer_store)r�daemonZ
global_config)�	__class__rr
r+s
zController.__init__cCsptjd�|j�}|jjtjtj�}|r6|r6tj�|rZ|j	j
�x|jj|j	d�sXqFWtjd�|j
�dS)z1
		Controller main loop. The call is blocking.
		zstarting controller�
zterminating controllerN)�log�info�startr�get_bool�consts�
CFG_DAEMON�CFG_DEF_DAEMONrrrr�wait�stop)r�resr rrr
�run3s



zController.runcCs|jj�dS)N)r�set)rrrr
�	terminateFszController.terminateZsbscCsdS)Nr)r�profile_name�resultZerrstrrrr
�profile_changedIszController.profile_changedcCstjj|�|jj|�dS)N)�tuned�logs�log_capture_finishrr)rrrrr
�_log_capture_abortRszController._log_capture_abortZii�sNcCsf|dkrdStjj|�}|dkr$dS|dkrVtj||j|gd�}|jj||�|j�|dkrbdS|S)N�r)�args)	r3r4�log_capture_startr	ZTimerr6rrr%)rZ	log_levelZtimeout�callerrrrrr
r:VszController.log_capture_startcCs4|dkrdStjj|�}|jj|�|dkr0dS|S)Nr8)r3r4r5rr)rrr;r,rrr
r5ds
zController.log_capture_finishr8�bcCsD|dkrdS|jjtjtj�r:|jj�r,dS|jj�s:dS|jj�S)Nr8FT)	rr&r'r(r)r�
is_running�
is_enabledr%)rr;rrr
r%ls

zController.startcCs4|dkrdS|jj�sd}n
|jj�}|jj�|S)Nr8FT)rr=r+rr)rr;r,rrr
r+ws


zController.stopcCsl|dkrdS|jj�r&|j�}|s&dSy|jj�Wn.tk
rb}ztjd|�dSd}~XnX|j�S)Nr8FzFailed to reload TuneD: %s)rr=r+Zreload_profile_configrr#�errorr%)rr;Zstop_ok�errr
�reload�s
zController.reloadcCs�|jj�}d}d}d}z�y$|r,|jjdd�|jj||�Wnftjjk
r�}zFd}t|�}|r�|jjj	|kr�t
jd|�d}nt
jd|�WYdd}~XnXWd|r�|r�t
jd|�n|s�t
j
d�|jj�X||fS)	NZOKTF)Zprofile_switchz@Failed to reapply profile '%s'. Did it change on disk and break?zFailed to apply profile '%s'z>Applying previously applied (possibly out-dated) profile '%s'.z$Applying previously applied profile.)rr=r+Zset_profiler3�
exceptionsr�str�profile�namer#r?�warnr$r%)rr0�manualZwas_running�msg�successZreapplyr@rrr
�_switch_profile�s,
$
zController._switch_profilez(bs)cCs|dkrdS|j|d�S)Nr8F�UnauthorizedT)FrK)rJ)rr0r;rrr
�switch_profile�szController.switch_profilecCs |dkrdS|j�}|j|d�S)Nr8FrK)FrK)�recommend_profilerJ)rr;r0rrr
�auto_profile�szController.auto_profilecCs*|dkrdS|jjdk	r"|jjjSdSdS)Nr8)rrDrE)rr;rrr
�active_profile�s

zController.active_profilez(ss)cCs�|dkrdS|jj}|dkrpy"|jj�\}}|dkr<|dk	}Wn0tk
rn}zd}t|�}||fSd}~XnX|rztjntj}|dfS)Nr8�unknownrK)rPrK)	rrGrZget_active_profilerrCr'ZACTIVE_PROFILE_MANUALZACTIVE_PROFILE_AUTO)rr;rGrDr@�moder?rrr
�profile_mode�szController.profile_modecCs|dkrdS|jjpdS)Nr8)r�post_loaded_profile)rr;rrr
rS�szController.post_loaded_profilecCsB|dkrdS|jj�r |jj�|jj�r>|jjddddd�dS)Nr8FT)Zsave_instantly)rr=r+r>Zset_all_profiles)rr;rrr
�disable�s


zController.disablecCs|dkrdS|jj�S)Nr8F)rr=)rr;rrr
r=�szController.is_running�ascCs|dkrgS|jjjj�S)Nr8)r�profile_loader�profile_locatorZget_known_names)rr;rrr
�profiles�szController.profilesza(ss)cCs|dkrgS|jjjj�S)Nr8)rrVrWZget_known_names_summary)rr;rrr
�	profiles2�szController.profiles2z(bsss)cCsP|dkrtdddd�S|dks&|dkr.|j�}t|jjjj|tjtjgdg��S)Nr8F)	�tuplerOrrVrWZget_profile_attrsr'ZPROFILE_ATTR_SUMMARYZPROFILE_ATTR_DESCRIPTION)rr0r;rrr
�profile_info�s
zController.profile_infocCs|dkrdS|jjj�S)Nr8)rZprofile_recommenderZ	recommend)rr;rrr
rM�szController.recommend_profilecCs|dkrdS|jjdd�S)Nr8F)�ignore_missing)r�verify_profile)rr;rrr
r]szController.verify_profilecCs|dkrdS|jjdd�S)Nr8FT)r\)rr])rr;rrr
�verify_profile_ignore_missingsz(Controller.verify_profile_ignore_missingz	a{sa{ss}}cCsz|dkrdSi}xd|jj�D]V}|jjd�djdd�d}|j�}i||<x$|j�D]\}}t|�|||<qVWqW|S)zuReturn dictionary with accesible plugins

		Return:
		dictionary -- {plugin_name: {parameter_name: default_value}}
		r8F�.��_���)r�get_all_pluginsr�splitZ_get_config_options�itemsrC)rr;ZpluginsZplugin_class�plugin_nameZconf_options�key�valrrr
rcszController.get_all_pluginscCs|dkrdS|jjt|��S)z"Return docstring of plugin's classr8F)r�get_plugin_documentationrC)rrfr;rrr
ri#sz#Controller.get_plugin_documentationza{ss}cCs|dkrdS|jjt|��S)z�Return dictionary with plugin's parameters and their hints

		Parameters:
		plugin_name -- name of plugin

		Return:
		dictionary -- {parameter_name: hint}
		r8F)r�get_plugin_hintsrC)rrfr;rrr
rj*s
zController.get_plugin_hints)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)#rrr�__doc__rr-r/r�signalr2r6Zexportr:r5r%r+rArJrLrNrOrRrSrTr=rXrYr[rMr]r^rcrirj�
__classcell__rr)r!r
r%sb	























)r3rZ
tuned.logsZtuned.exceptionsrr	Ztuned.constsr'Ztuned.utils.commandsr�__all__r4�getr#�objectrZ
interfacesZExportableInterfacerrrrr
�<module>s