ok

Mini Shell

Direktori : /lib/python3.6/site-packages/tuned/units/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/tuned/units/__pycache__/manager.cpython-36.pyc

3

�<�e��@s~ddlZddlZddlZddlZddlZddlZddlZddlj	Z	ddl
mZddlm
Z
ejj�ZdgZGdd�de�ZdS)�N)�GlobalConfig)�commands�Managercs�eZdZdZd�fdd�	Zedd��Zedd��Zed	d
��Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zejfdd�Z�ZS) rz?
	Manager creates plugin instances and keeps a track of them.
	NcsJtt|�j�||_||_||_||_g|_g|_|p:t	�|_
t�|_dS)N)
�superr�__init__�_plugins_repository�_monitors_repository�_def_instance_priority�_hardware_inventory�
_instances�_pluginsr�_configr�_cmd)�self�plugins_repositoryZmonitors_repositoryZdef_instance_priorityZhardware_inventory�config)�	__class__��/usr/lib/python3.6/manager.pyrszManager.__init__cCs|jS)N)r)rrrr�plugins!szManager.pluginscCs|jS)N)r)rrrr�	instances%szManager.instancescCs|jS)N)r)rrrrr)szManager.plugins_repositorycCsF|jdkrdS|jjtj�}|dkr0|jjd�}tj|j|tj	�dk	S)NTz
/proc/cpuinfo)
Z
cpuinfo_regexr
�get�constsZCFG_CPUINFO_STRINGrZ	read_file�re�search�	MULTILINE)r�unitZcpuinfo_stringrrr�_unit_matches_cpuinfo-s

zManager._unit_matches_cpuinfocCsH|jdkrdS|jjtj�}|dkr2djtj��}tj	|j|tj
�dk	S)NT� )Zuname_regexr
rrZCFG_UNAME_STRING�join�os�unamerrr)rrZuname_stringrrr�_unit_matches_uname6s

zManager._unit_matches_unamec
Cs2g}x�t|j��D]�\}}|js0tjd|�q|j|�sJtjd|�q|j|�sdtjd|�q|jjd|j	�t
|jd�|jd<|j|�qW|jdd�d�t
j�}x"|D]}|jjd�d||j<q�Wx�t|j��D]�\}}y$|jj|�}|||<|jj|�Wq�tjjjk
�r8tjd|�w�Yq�tk
�rt}	z tjd	|�tj|	�w�WYdd}	~	Xq�Xq�Wg}
xf|D]^}||j}|dk�r��q�tjd
|j|jf�|j|j|j|j|j |j!|j�}|
j|��q�Wx0|
D](}|j"j#�|j"j$|�|j"j%|��q�W|j&j'�|j(j)|
�dS)Nzskipping disabled instance '%s'z.skipping instance '%s', cpuinfo does not matchz,skipping instance '%s', uname does not match�prioritycSs
|jdS)Nr#)�options)�xrrr�<lambda>Psz Manager.create.<locals>.<lambda>)�keyz2skipping plugin '%s', not supported on your systemzfailed to initialize plugin %szcreating '%s' (%s))*�list�itemsZenabled�log�debugrr"r$�
setdefaultr	�int�append�sort�collections�OrderedDict�pop�typer�creater�tunedr�
exceptionsZNotSupportedPluginException�info�	Exception�errorZ	exception�nameZcreate_instanceZdevicesZdevices_udev_regexZ
script_preZscript_post�pluginZinit_devicesZassign_free_devicesZinitialize_instancer
Zstart_processing_eventsr�extend)
rZinstances_configZinstance_info_listZ
instance_nameZ
instance_infoZplugins_by_nameZplugin_nameZnoner;�erZnew_instance�instancerrrr4?s\









zManager.createcOsXy
|||�Stk
rR}z,tj�}tjd|t|�f�tj|�|Sd}~XnXdS)Nz"BUG: Unhandled exception in %s: %s)r8�	traceback�
format_excr*r9�str)rZcallerZexc_ret�f�args�kwargsr=Ztracerrr�	_try_callus

zManager._try_callcCs�x2|jD](}tjd|j�|jdd|jj|�qWx.|jD]$}tjd|j�|jdd|j�q<W|jdd�=|jdd�=dS)Nzdestroying instance %s�destroy_allzcleaning plugin '%s')	rr*r+r:rEr;Zdestroy_instancerZcleanup)rr>r;rrrrFs
zManager.destroy_allcCs4x.|jjD]"}tjd|�|jdd|j�q
WdS)Nzupdating monitor %s�update_monitors)rZmonitorsr*r+rE�update)rZmonitorrrrrG�szManager.update_monitorscCs$x|jD]}|jdd|j�qWdS)N�start_tuning)rrEZapply_tuning)rr>rrrrI�szManager.start_tuningcCs6d}x,|jD]"}|jdd|j|�}|dkrd}qW|S)NT�
verify_tuningF)rrErJ)rZignore_missing�retr>�resrrrrJ�s
zManager.verify_tuningcCs$x|jD]}|jdd|j�qWdS)N�
update_tuning)rrErM)rr>rrrrM�szManager.update_tuningcCs4|jj�x$t|j�D]}|jdd|j|�qWdS)N�stop_tuning)r
Zstop_processing_events�reversedrrEZunapply_tuning)rZrollbackr>rrrrN�s
zManager.stop_tuning)N)�__name__�
__module__�__qualname__�__doc__r�propertyrrrrr"r4rErFrGrIrJrMrZ
ROLLBACK_SOFTrN�
__classcell__rr)rrrs		6

	
)r0r rr?Ztuned.exceptionsr5Z
tuned.logsZtuned.plugins.exceptionsZtuned.constsrZtuned.utils.global_configrZtuned.utils.commandsrZlogsrr*�__all__�objectrrrrr�<module>s



Zerion Mini Shell 1.0