ok

Mini Shell

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

3

�<�e��@s�ddlmZmZddlmZddlmZddlmZm	Z	m
Z
ddlmZddl
Z
ddlZddlZej�ZdZdZd	ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�dejj�ZdS)�)�exports�logs)�commands)�PPD_CONFIG_FILE)�	PPDConfig�PPD_PERFORMANCE�PPD_POWER_SAVER)�StrEnumN�tunedz-/sys/devices/system/cpu/intel_pstate/no_turboz4/sys/bus/platform/devices/thinkpad_acpi/dytc_lapmodec@seZdZdZdZdZdS)�PerformanceDegraded�zlap-detectedzhigh-operating-temperatureN)�__name__�
__module__�__qualname__�NONE�LAP_DETECTED�HIGH_OPERATING_TEMPERATURE�rr� /usr/lib/python3.6/controller.pyrsrc@seZdZdd�Zdd�ZdS)�ProfileHoldcCs||_||_||_||_dS)N)�profile�reason�app_id�watch)�selfrrrrrrr�__init__szProfileHold.__init__cCs|j|j|jd�S)N)�ProfileZReasonZ
ApplicationId)rrr)rrrr�as_dictszProfileHold.as_dictN)r
rrrrrrrrrsrc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�ProfileHoldManagercCsi|_d|_||_dS)Nr)�_holds�_cookie_counter�_controller)rZ
controllerrrrr'szProfileHoldManager.__init__cs���fdd�}|S)Ncs(|dkr$tjd��f��j��dS)Nrz1Application '%s' disappeared, releasing hold '%s')�log�info�remove)�name)r�cookierrr�callback-sz.ProfileHoldManager._callback.<locals>.callbackr)rr&rr'r)rr&rr�	_callback,szProfileHoldManager._callbackcCs tdd�|jj�D��rtStS)Ncss|]}|jtkVqdS)N)rr)�.0�holdrrr�	<genexpr>5sz=ProfileHoldManager._effective_hold_profile.<locals>.<genexpr>)�anyr�valuesrr)rrrr�_effective_hold_profile4sz*ProfileHoldManager._effective_hold_profilecCs\||jkrdS|jj|�}|jj�tjd|�tjd|j��tj	d||j
|jf�dS)N�ProfileReleased�ActiveProfileHoldsz5Releasing hold '%s': profile '%s' by application '%s')r�poprZcancelrZsend_signal�property_changed�
as_dbus_arrayr"r#rr)rr&r*rrr�_cancel9s

zProfileHoldManager._cancelcCstjdd�|jj�D�dd�S)NcSsg|]}|j��qSr)r)r)r*rrr�
<listcomp>Csz4ProfileHoldManager.as_dbus_array.<locals>.<listcomp>za{sv})�	signature)�dbus�Arrayrr-)rrrrr3Bsz ProfileHoldManager.as_dbus_arraycCst|j}|jd7_|jjj||j||��}tjd|||f�t||||�|j|<t	j
d|j��|jj|�|S)N�z2Adding hold '%s': profile '%s' by application '%s'r0)
r r!�busZwatch_name_ownerr(r"r#rrrr2r3�switch_profile)rrrr�callerr&rrrr�addEszProfileHoldManager.addcCs
||jkS)N)r)rr&rrr�hasOszProfileHoldManager.hascCs:|j|�t|j�dkr"|j�}n|jj}|jj|�dS)Nr)r4�lenrr.r!�base_profiler;)rr&Znew_profilerrrr$Rs


zProfileHoldManager.removecCsx|jD]}|j|�qWdS)N)rr4)rr&rrr�clearZszProfileHoldManager.clearN)r
rrrr(r.r4r3r=r>r$rArrrrr&s	
rcs
eZdZ�fdd�Zdd�Zdd�Zedd��Zed	d
��Zdd�Z	d
d�Z
dd�Zdd�Ze
jdd�dd��Ze
jdd�dd��Ze
jd�dd��Ze
jd�dd��Ze
jd�dd ��Ze
jd!�d"d#��Ze
jd$�d%d&��Ze
jd'�d(d)��Ze
jd*�d+d,��Z�ZS)-�
ControllercsJtt|�j�||_||_t|�|_tj|_	t
�|_tj
�|_|j�dS)N)�superrBr�_bus�_tuned_interfacer�_profile_holdsrr�_performance_degradedr�_cmd�	threadingZEvent�
_terminate�load_config)rr:Ztuned_interface)�	__class__rrr`s

zController.__init__cCs�tj}tjjt�r,t|jjt��dkr,tj	}tjjt
�rRt|jjt
��dkrRtj}||jkr|t
jd|�||_tjd|�dS)Nr9zPerformance degraded: %sr)rr�os�path�exists�
NO_TURBO_PATH�intrHZ	read_filer�
LAP_MODE_PATHrrGr"r#rr2)rZperformance_degradedrrr�_check_performance_degradedjs
z&Controller._check_performance_degradedcCs2tj�x|jj|jd�s$|j�q
Wtj�dS)Nr9)r�startrH�waitrJrS�stop)rrrr�runwszController.runcCs|jS)N)rD)rrrrr:}szController.buscCs|jS)N)�
_base_profile)rrrrr@�szController.base_profilecCs|jj�dS)N)rJ�set)rrrr�	terminate�szController.terminatecCs&tt�|_|jj|_|j|jj�dS)N)rr�_configZdefault_profilerXr;)rrrrrK�s

zController.load_configcCsF|j�|krdS|jj|}tjd|�|jj|�tjd|�dS)NzSwitching to profile '%s'�
ActiveProfile)	�active_profiler[�ppd_to_tunedr"r#rEr;rr2)rr�
tuned_profilerrrr;�szController.switch_profilecCs|jj�}|jjj|d�S)N�unknown)rEr]r[Ztuned_to_ppd�get)rr_rrrr]�s
zController.active_profileZsss�ucCs6|tkr$|tkr$tjjdttf��|jj||||�S)Nz'Only '%s' and '%s' profiles may be held)rrr7�
exceptions�
DBusExceptionrFr=)rrrrr<rrr�HoldProfile�szController.HoldProfilercCs,|jj|�stjjd|��|jj|�dS)NzNo active hold for cookie '%s')rFr>r7rcrdr$)rr&r<rrr�ReleaseProfile�szController.ReleaseProfilecCsdS)Nr)rr&rrrr/�szController.ProfileReleasedr\cCs:||jjkrtjjd|��||_|jj�|j|�dS)NzInvalid profile '%s')	r[r^r7rcrdrXrFrAr;)rrrrr�set_active_profile�s

zController.set_active_profilecCs|j�S)N)r])rrrr�get_active_profile�szController.get_active_profileZProfilescCs tjdd�|jjj�D�dd�S)NcSsg|]}|td��qS))rZDriver)�DRIVER)r)rrrrr5�sz+Controller.get_profiles.<locals>.<listcomp>za{sv})r6)r7r8r[r^�keys)rrrr�get_profiles�szController.get_profilesZActionscCstjgdd�S)N�s)r6)r7r8)rrrr�get_actions�szController.get_actionsrcCs|jS)N)rG)rrrr�get_performance_degraded�sz#Controller.get_performance_degradedr0cCs
|jj�S)N)rFr3)rrrr�get_active_profile_holds�sz#Controller.get_active_profile_holds)r
rrrrSrW�propertyr:r@rZrKr;r]rZexportrerf�signalr/Zproperty_setterrgZproperty_getterrhrkrmrnro�
__classcell__rr)rLrrB_s$

rB)r
rrZtuned.utils.commandsrZtuned.constsrZtuned.ppd.configrrr�enumr	rIr7rMrar"rirPrRr�objectrrZ
interfacesZExportableInterfacerBrrrr�<module>s9

Zerion Mini Shell 1.0