Current File : /home/mmdealscpanel/yummmdeals.com/ppd.zip
PK�t[CEj���ppd.confnu�[���[main]
# The default PPD profile
default=balanced

[profiles]
# PPD = TuneD
power-saver=powersave
balanced=balanced
performance=throughput-performance
PK�t[;�>�,,tuned-ppd.servicenu�[���[Unit]
Description=PPD-to-TuneD API Translation Daemon
Requires=tuned.service
After=tuned.service
Before=multi-user.target display-manager.target

[Service]
Type=dbus
PIDFile=/run/tuned/tuned-ppd.pid
BusName=net.hadess.PowerProfiles
ExecStart=/usr/sbin/tuned-ppd

[Install]
WantedBy=graphical.target
PK�t[�&�^iituned-ppd.dbus.servicenu�[���[D-BUS Service]
Name=net.hadess.PowerProfiles
Exec=/bin/false
User=root
SystemdService=tuned-ppd.service
PK�t[���7�!�!%__pycache__/controller.cpython-36.pycnu�[���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9PK�t[%r�

'__pycache__/config.cpython-36.opt-1.pycnu�[���3

�<�eQ	�@sJddlmZmZddlmZddlZdZdZdZdZ	dZ
Gd	d
�d
�ZdS)�)�ConfigParser�Error)�TunedExceptionNzpower-saverZperformance�mainZprofiles�defaultc@s@eZdZdd�Zedd��Zedd��Zedd��Zd	d
�ZdS)�	PPDConfigcCs|j|�dS)N)�load_from_file)�self�config_file�r�/usr/lib/python3.6/config.py�__init__szPPDConfig.__init__cCs|jS)N)�_default_profile)r	rrr�default_profileszPPDConfig.default_profilecCs|jS)N)�
_ppd_to_tuned)r	rrr�ppd_to_tunedszPPDConfig.ppd_to_tunedcCs|jS)N)�
_tuned_to_ppd)r	rrr�tuned_to_ppdszPPDConfig.tuned_to_ppdcCsRt�}tjj|�std|��y|j|�Wn tk
rLtd|��YnXt|krbtd|��t|t�|_	t
dd�|j	j�D��s�td|��tt
|j	j���t|j	�kr�td|��dd	�|j	j�D�|_t|j	kr�td
|��t|j	k�rtd|��t|k�st|tk�r$td|��|tt|_|j|j	k�rNtd
|j��dS)Nz&Configuration file '%s' does not existz)Error parsing the configuration file '%s'z7Missing profiles section in the configuration file '%s'css|]}t|t�VqdS)N)�
isinstance�str)�.0Zmapped_profilerrr�	<genexpr>+sz+PPDConfig.load_from_file.<locals>.<genexpr>z6Invalid profile mapping in the configuration file '%s'z8Duplicate profile mapping in the configuration file '%s'cSsi|]\}}||�qSrr)r�k�vrrr�
<dictcomp>0sz,PPDConfig.load_from_file.<locals>.<dictcomp>z:Missing power-saver profile in the configuration file '%s'z:Missing performance profile in the configuration file '%s'z6Missing default profile in the configuration file '%s'zUnknown default profile '%s')r�os�path�isfiler�readr�PROFILES_SECTION�dictr�all�values�len�set�itemsr�PPD_POWER_SAVER�PPD_PERFORMANCE�MAIN_SECTION�DEFAULT_PROFILE_OPTIONr)r	r
Zcfgrrrrs0
zPPDConfig.load_from_fileN)	�__name__�
__module__�__qualname__r
�propertyrrrrrrrrr
s
r)Ztuned.utils.config_parserrrZtuned.exceptionsrrr&r'r(rr)rrrrr�<module>sPK�t[%r�

!__pycache__/config.cpython-36.pycnu�[���3

�<�eQ	�@sJddlmZmZddlmZddlZdZdZdZdZ	dZ
Gd	d
�d
�ZdS)�)�ConfigParser�Error)�TunedExceptionNzpower-saverZperformance�mainZprofiles�defaultc@s@eZdZdd�Zedd��Zedd��Zedd��Zd	d
�ZdS)�	PPDConfigcCs|j|�dS)N)�load_from_file)�self�config_file�r�/usr/lib/python3.6/config.py�__init__szPPDConfig.__init__cCs|jS)N)�_default_profile)r	rrr�default_profileszPPDConfig.default_profilecCs|jS)N)�
_ppd_to_tuned)r	rrr�ppd_to_tunedszPPDConfig.ppd_to_tunedcCs|jS)N)�
_tuned_to_ppd)r	rrr�tuned_to_ppdszPPDConfig.tuned_to_ppdcCsRt�}tjj|�std|��y|j|�Wn tk
rLtd|��YnXt|krbtd|��t|t�|_	t
dd�|j	j�D��s�td|��tt
|j	j���t|j	�kr�td|��dd	�|j	j�D�|_t|j	kr�td
|��t|j	k�rtd|��t|k�st|tk�r$td|��|tt|_|j|j	k�rNtd
|j��dS)Nz&Configuration file '%s' does not existz)Error parsing the configuration file '%s'z7Missing profiles section in the configuration file '%s'css|]}t|t�VqdS)N)�
isinstance�str)�.0Zmapped_profilerrr�	<genexpr>+sz+PPDConfig.load_from_file.<locals>.<genexpr>z6Invalid profile mapping in the configuration file '%s'z8Duplicate profile mapping in the configuration file '%s'cSsi|]\}}||�qSrr)r�k�vrrr�
<dictcomp>0sz,PPDConfig.load_from_file.<locals>.<dictcomp>z:Missing power-saver profile in the configuration file '%s'z:Missing performance profile in the configuration file '%s'z6Missing default profile in the configuration file '%s'zUnknown default profile '%s')r�os�path�isfiler�readr�PROFILES_SECTION�dictr�all�values�len�set�itemsr�PPD_POWER_SAVER�PPD_PERFORMANCE�MAIN_SECTION�DEFAULT_PROFILE_OPTIONr)r	r
Zcfgrrrrs0
zPPDConfig.load_from_fileN)	�__name__�
__module__�__qualname__r
�propertyrrrrrrrrr
s
r)Ztuned.utils.config_parserrrZtuned.exceptionsrrr&r'r(rr)rrrrr�<module>sPK�t[���7�!�!+__pycache__/controller.cpython-36.opt-1.pycnu�[���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9PK�t[���tuned-ppd.policynu�[���<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>

  <vendor>TuneD</vendor>
  <vendor_url>https://tuned-project.org/</vendor_url>

  <action id="net.hadess.PowerProfiles.HoldProfile">
    <description>Hold power profile</description>
    <message>Authentication is required to hold power profiles.</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>
  
  <action id="net.hadess.PowerProfiles.ReleaseProfile">
    <description>Release power profile</description>
    <message>Authentication is required to release power profiles.</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

</policyconfig>
PK�t[+�VQ	Q		config.pynu�[���from tuned.utils.config_parser import ConfigParser, Error
from tuned.exceptions import TunedException
import os

PPD_POWER_SAVER = "power-saver"
PPD_PERFORMANCE = "performance"

MAIN_SECTION = "main"
PROFILES_SECTION = "profiles"
DEFAULT_PROFILE_OPTION = "default"


class PPDConfig:
    def __init__(self, config_file):
        self.load_from_file(config_file)

    @property
    def default_profile(self):
        return self._default_profile

    @property
    def ppd_to_tuned(self):
        return self._ppd_to_tuned

    @property
    def tuned_to_ppd(self):
        return self._tuned_to_ppd

    def load_from_file(self, config_file):
        cfg = ConfigParser()

        if not os.path.isfile(config_file):
            raise TunedException("Configuration file '%s' does not exist" % config_file)
        try:
            cfg.read(config_file)
        except Error:
            raise TunedException("Error parsing the configuration file '%s'" % config_file)

        if PROFILES_SECTION not in cfg:
            raise TunedException("Missing profiles section in the configuration file '%s'" % config_file)
        self._ppd_to_tuned = dict(cfg[PROFILES_SECTION])

        if not all(isinstance(mapped_profile, str) for mapped_profile in self._ppd_to_tuned.values()):
            raise TunedException("Invalid profile mapping in the configuration file '%s'" % config_file)

        if len(set(self._ppd_to_tuned.values())) != len(self._ppd_to_tuned):
            raise TunedException("Duplicate profile mapping in the configuration file '%s'" % config_file)
        self._tuned_to_ppd = {v: k for k, v in self._ppd_to_tuned.items()}

        if PPD_POWER_SAVER not in self._ppd_to_tuned:
            raise TunedException("Missing power-saver profile in the configuration file '%s'" % config_file)

        if PPD_PERFORMANCE not in self._ppd_to_tuned:
            raise TunedException("Missing performance profile in the configuration file '%s'" % config_file)

        if MAIN_SECTION not in cfg or DEFAULT_PROFILE_OPTION not in cfg[MAIN_SECTION]:
            raise TunedException("Missing default profile in the configuration file '%s'" % config_file)

        self._default_profile = cfg[MAIN_SECTION][DEFAULT_PROFILE_OPTION]
        if self._default_profile not in self._ppd_to_tuned:
            raise TunedException("Unknown default profile '%s'" % self._default_profile)
PK�t[8�����
controller.pynu�[���from tuned import exports, logs
from tuned.utils.commands import commands
from tuned.consts import PPD_CONFIG_FILE
from tuned.ppd.config import PPDConfig, PPD_PERFORMANCE, PPD_POWER_SAVER
from enum import StrEnum
import threading
import dbus
import os

log = logs.get()

DRIVER = "tuned"
NO_TURBO_PATH = "/sys/devices/system/cpu/intel_pstate/no_turbo"
LAP_MODE_PATH = "/sys/bus/platform/devices/thinkpad_acpi/dytc_lapmode"


class PerformanceDegraded(StrEnum):
    NONE = ""
    LAP_DETECTED = "lap-detected"
    HIGH_OPERATING_TEMPERATURE = "high-operating-temperature"


class ProfileHold(object):
    def __init__(self, profile, reason, app_id, watch):
        self.profile = profile
        self.reason = reason
        self.app_id = app_id
        self.watch = watch

    def as_dict(self):
        return {
            "Profile": self.profile,
            "Reason": self.reason,
            "ApplicationId": self.app_id,
        }


class ProfileHoldManager(object):
    def __init__(self, controller):
        self._holds = {}
        self._cookie_counter = 0
        self._controller = controller

    def _callback(self, cookie, app_id):
        def callback(name):
            if name == "":
                log.info("Application '%s' disappeared, releasing hold '%s'" % (app_id, cookie))
                self.remove(cookie)

        return callback

    def _effective_hold_profile(self):
        if any(hold.profile == PPD_POWER_SAVER for hold in self._holds.values()):
            return PPD_POWER_SAVER
        return PPD_PERFORMANCE

    def _cancel(self, cookie):
        if cookie not in self._holds:
            return
        hold = self._holds.pop(cookie)
        hold.watch.cancel()
        exports.send_signal("ProfileReleased", cookie)
        exports.property_changed("ActiveProfileHolds", self.as_dbus_array())
        log.info("Releasing hold '%s': profile '%s' by application '%s'" % (cookie, hold.profile, hold.app_id))

    def as_dbus_array(self):
        return dbus.Array([hold.as_dict() for hold in self._holds.values()], signature="a{sv}")

    def add(self, profile, reason, app_id, caller):
        cookie = self._cookie_counter
        self._cookie_counter += 1
        watch = self._controller.bus.watch_name_owner(caller, self._callback(cookie, app_id))
        log.info("Adding hold '%s': profile '%s' by application '%s'" % (cookie, profile, app_id))
        self._holds[cookie] = ProfileHold(profile, reason, app_id, watch)
        exports.property_changed("ActiveProfileHolds", self.as_dbus_array())
        self._controller.switch_profile(profile)
        return cookie

    def has(self, cookie):
        return cookie in self._holds

    def remove(self, cookie):
        self._cancel(cookie)
        if len(self._holds) != 0:
            new_profile = self._effective_hold_profile()
        else:
            new_profile = self._controller.base_profile
        self._controller.switch_profile(new_profile)

    def clear(self):
        for cookie in self._holds:
            self._cancel(cookie)


class Controller(exports.interfaces.ExportableInterface):
    def __init__(self, bus, tuned_interface):
        super(Controller, self).__init__()
        self._bus = bus
        self._tuned_interface = tuned_interface
        self._profile_holds = ProfileHoldManager(self)
        self._performance_degraded = PerformanceDegraded.NONE
        self._cmd = commands()
        self._terminate = threading.Event()
        self.load_config()

    def _check_performance_degraded(self):
        performance_degraded = PerformanceDegraded.NONE
        if os.path.exists(NO_TURBO_PATH):
            if int(self._cmd.read_file(NO_TURBO_PATH)) == 1:
                performance_degraded = PerformanceDegraded.HIGH_OPERATING_TEMPERATURE
        if os.path.exists(LAP_MODE_PATH):
            if int(self._cmd.read_file(LAP_MODE_PATH)) == 1:
                performance_degraded = PerformanceDegraded.LAP_DETECTED
        if performance_degraded != self._performance_degraded:
            log.info("Performance degraded: %s" % performance_degraded)
            self._performance_degraded = performance_degraded
            exports.property_changed("PerformanceDegraded", performance_degraded)

    def run(self):
        exports.start()
        while not self._cmd.wait(self._terminate, 1):
            self._check_performance_degraded()
        exports.stop()

    @property
    def bus(self):
        return self._bus

    @property
    def base_profile(self):
        return self._base_profile

    def terminate(self):
        self._terminate.set()

    def load_config(self):
        self._config = PPDConfig(PPD_CONFIG_FILE)
        self._base_profile = self._config.default_profile
        self.switch_profile(self._config.default_profile)

    def switch_profile(self, profile):
        if self.active_profile() == profile:
            return
        tuned_profile = self._config.ppd_to_tuned[profile]
        log.info("Switching to profile '%s'" % tuned_profile)
        self._tuned_interface.switch_profile(tuned_profile)
        exports.property_changed("ActiveProfile", profile)

    def active_profile(self):
        tuned_profile = self._tuned_interface.active_profile()
        return self._config.tuned_to_ppd.get(tuned_profile, "unknown")

    @exports.export("sss", "u")
    def HoldProfile(self, profile, reason, app_id, caller):
        if profile != PPD_POWER_SAVER and profile != PPD_PERFORMANCE:
            raise dbus.exceptions.DBusException(
                "Only '%s' and '%s' profiles may be held" % (PPD_POWER_SAVER, PPD_PERFORMANCE)
            )
        return self._profile_holds.add(profile, reason, app_id, caller)

    @exports.export("u", "")
    def ReleaseProfile(self, cookie, caller):
        if not self._profile_holds.has(cookie):
            raise dbus.exceptions.DBusException("No active hold for cookie '%s'" % cookie)
        self._profile_holds.remove(cookie)

    @exports.signal("u")
    def ProfileReleased(self, cookie):
        pass

    @exports.property_setter("ActiveProfile")
    def set_active_profile(self, profile):
        if profile not in self._config.ppd_to_tuned:
            raise dbus.exceptions.DBusException("Invalid profile '%s'" % profile)
        self._base_profile = profile
        self._profile_holds.clear()
        self.switch_profile(profile)

    @exports.property_getter("ActiveProfile")
    def get_active_profile(self):
        return self.active_profile()

    @exports.property_getter("Profiles")
    def get_profiles(self):
        return dbus.Array(
            [{"Profile": profile, "Driver": DRIVER} for profile in self._config.ppd_to_tuned.keys()],
            signature="a{sv}",
        )

    @exports.property_getter("Actions")
    def get_actions(self):
        return dbus.Array([], signature="s")

    @exports.property_getter("PerformanceDegraded")
    def get_performance_degraded(self):
        return self._performance_degraded

    @exports.property_getter("ActiveProfileHolds")
    def get_active_profile_holds(self):
        return self._profile_holds.as_dbus_array()
PK�t["z�a��	dbus.confnu�[���<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
  <policy user="root">
    <allow own="net.hadess.PowerProfiles"/>
  </policy>

  <policy context="default">
    <allow send_destination="net.hadess.PowerProfiles" send_interface="net.hadess.PowerProfiles"/>
    <allow send_destination="net.hadess.PowerProfiles" send_interface="org.freedesktop.DBus.Introspectable"/>
    <allow send_destination="net.hadess.PowerProfiles" send_interface="org.freedesktop.DBus.Properties"/>
    <allow send_destination="net.hadess.PowerProfiles" send_interface="org.freedesktop.DBus.Peer"/>
  </policy>
</busconfig>
PK�t[CEj���ppd.confnu�[���PK�t[;�>�,,�tuned-ppd.servicenu�[���PK�t[�&�^ii<tuned-ppd.dbus.servicenu�[���PK�t[���7�!�!%�__pycache__/controller.cpython-36.pycnu�[���PK�t[%r�

'4%__pycache__/config.cpython-36.opt-1.pycnu�[���PK�t[%r�

!�/__pycache__/config.cpython-36.pycnu�[���PK�t[���7�!�!+:__pycache__/controller.cpython-36.opt-1.pycnu�[���PK�t[���c\tuned-ppd.policynu�[���PK�t[+�VQ	Q		�`config.pynu�[���PK�t[8�����

jcontroller.pynu�[���PK�t["z�a��	�dbus.confnu�[���PK�,�