Server IP : 149.255.58.128 / Your IP : 216.73.216.74
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Upload Files :
Command :
Current File : /usr/lib/python3.9/site-packages/tuned/ppd//config.py
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"
BATTERY_SECTION = "battery"
DEFAULT_PROFILE_OPTION = "default"
BATTERY_DETECTION_OPTION = "battery_detection"
class PPDConfig:
def __init__(self, config_file):
self.load_from_file(config_file)
@property
def battery_detection(self):
return self._battery_detection
@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
@property
def ppd_to_tuned_battery(self):
return self._ppd_to_tuned_battery
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)
if BATTERY_DETECTION_OPTION not in cfg[MAIN_SECTION]:
raise TunedException("Missing battery detection option in the configuration file '%s'" % config_file)
self._ppd_to_tuned_battery = self._ppd_to_tuned
self._battery_detection = cfg.getboolean(MAIN_SECTION, BATTERY_DETECTION_OPTION)
if self._battery_detection:
if BATTERY_SECTION not in cfg:
raise TunedException("Missing battery section in the configuration file '%s'" % config_file)
for k, _v in dict(cfg[PROFILES_SECTION]).items():
if k in cfg[BATTERY_SECTION].keys():
self._tuned_to_ppd = self._tuned_to_ppd | {cfg[BATTERY_SECTION][k]:k}
for k, v in dict(cfg[BATTERY_SECTION]).items():
if k in cfg[PROFILES_SECTION].keys():
self._ppd_to_tuned_battery = self._ppd_to_tuned_battery | {k:v}
Name |
Size |
Last Modified |
Owner / Group |
Permissions |
Options |
.. | -- | December 04 2024 22:44:57 | 0 / root | 0755 | |
__pycache__ | -- | December 04 2024 22:44:57 | 0 / root | 0755 | |
| | | | | |
config.py | 3.47 KB | August 07 2024 20:09:40 | 0 / root | 0644 | |
controller.py | 8.309 KB | August 07 2024 20:09:40 | 0 / root | 0644 | |
dbus.conf | 0.729 KB | August 07 2024 20:09:40 | 0 / root | 0644 | |
ppd.conf | 0.22 KB | August 07 2024 20:09:40 | 0 / root | 0644 | |
tuned-ppd.dbus.service | 0.103 KB | August 07 2024 20:09:40 | 0 / root | 0644 | |
tuned-ppd.policy | 0.969 KB | August 07 2024 20:09:40 | 0 / root | 0644 | |
tuned-ppd.service | 0.264 KB | August 07 2024 20:09:40 | 0 / root | 0644 | |