golden hour
/lib/python2.7/site-packages/tuned/plugins
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.py
49 B
Del
OK
__init__.pyc
232 B
Del
OK
__init__.pyo
232 B
Del
OK
base.py
21.7 KB
Del
OK
base.pyc
24.43 KB
Del
OK
base.pyo
24.43 KB
Del
OK
decorators.py
983 B
Del
OK
decorators.pyc
1.52 KB
Del
OK
decorators.pyo
1.52 KB
Del
OK
exceptions.py
99 B
Del
OK
exceptions.pyc
460 B
Del
OK
exceptions.pyo
460 B
Del
OK
hotplug.py
2.97 KB
Del
OK
hotplug.pyc
4.09 KB
Del
OK
hotplug.pyo
4.09 KB
Del
OK
instance
-
Del
OK
plugin_audio.py
2.46 KB
Del
OK
plugin_audio.pyc
4.36 KB
Del
OK
plugin_audio.pyo
4.36 KB
Del
OK
plugin_bootloader.py
12.6 KB
Del
OK
plugin_bootloader.pyc
15.47 KB
Del
OK
plugin_bootloader.pyo
15.47 KB
Del
OK
plugin_cpu.py
12.95 KB
Del
OK
plugin_cpu.pyc
15.46 KB
Del
OK
plugin_cpu.pyo
15.42 KB
Del
OK
plugin_disk.py
13.77 KB
Del
OK
plugin_disk.pyc
16.92 KB
Del
OK
plugin_disk.pyo
16.92 KB
Del
OK
plugin_eeepc_she.py
2.04 KB
Del
OK
plugin_eeepc_she.pyc
3.3 KB
Del
OK
plugin_eeepc_she.pyo
3.3 KB
Del
OK
plugin_modules.py
3.8 KB
Del
OK
plugin_modules.pyc
5.64 KB
Del
OK
plugin_modules.pyo
5.64 KB
Del
OK
plugin_mounts.py
5.17 KB
Del
OK
plugin_mounts.pyc
6.36 KB
Del
OK
plugin_mounts.pyo
6.36 KB
Del
OK
plugin_net.py
14.02 KB
Del
OK
plugin_net.pyc
16.5 KB
Del
OK
plugin_net.pyo
16.5 KB
Del
OK
plugin_scheduler.py
23.2 KB
Del
OK
plugin_scheduler.pyc
25.28 KB
Del
OK
plugin_scheduler.pyo
25.28 KB
Del
OK
plugin_script.py
2.47 KB
Del
OK
plugin_script.pyc
3.77 KB
Del
OK
plugin_script.pyo
3.71 KB
Del
OK
plugin_scsi_host.py
2.59 KB
Del
OK
plugin_scsi_host.pyc
5.01 KB
Del
OK
plugin_scsi_host.pyo
5.01 KB
Del
OK
plugin_selinux.py
1.56 KB
Del
OK
plugin_selinux.pyc
2.96 KB
Del
OK
plugin_selinux.pyo
2.96 KB
Del
OK
plugin_sysctl.py
5.45 KB
Del
OK
plugin_sysctl.pyc
7.33 KB
Del
OK
plugin_sysctl.pyo
7.33 KB
Del
OK
plugin_sysfs.py
2.05 KB
Del
OK
plugin_sysfs.pyc
3.77 KB
Del
OK
plugin_sysfs.pyo
3.77 KB
Del
OK
plugin_systemd.py
4.82 KB
Del
OK
plugin_systemd.pyc
6.87 KB
Del
OK
plugin_systemd.pyo
6.87 KB
Del
OK
plugin_usb.py
1.49 KB
Del
OK
plugin_usb.pyc
3.06 KB
Del
OK
plugin_usb.pyo
3.06 KB
Del
OK
plugin_video.py
2.81 KB
Del
OK
plugin_video.pyc
4.2 KB
Del
OK
plugin_video.pyo
4.2 KB
Del
OK
plugin_vm.py
2.74 KB
Del
OK
plugin_vm.pyc
4.31 KB
Del
OK
plugin_vm.pyo
4.31 KB
Del
OK
repository.py
1.49 KB
Del
OK
repository.pyc
2.46 KB
Del
OK
repository.pyo
2.4 KB
Del
OK
Edit: plugin_script.py
import tuned.consts as consts from . import base import tuned.logs import os from subprocess import Popen, PIPE log = tuned.logs.get() class ScriptPlugin(base.Plugin): """ Plugin for running custom scripts with profile activation and deactivation. """ @classmethod def _get_config_options(self): return { "script" : None, } def _instance_init(self, instance): instance._has_static_tuning = True instance._has_dynamic_tuning = False if instance.options["script"] is not None: # FIXME: this hack originated from profiles merger assert isinstance(instance.options["script"], list) instance._scripts = instance.options["script"] else: instance._scripts = [] def _instance_cleanup(self, instance): pass def _call_scripts(self, scripts, arguments): ret = True for script in scripts: environ = os.environ environ.update(self._variables.get_env()) log.info("calling script '%s' with arguments '%s'" % (script, str(arguments))) log.debug("using environment '%s'" % str(list(environ.items()))) try: proc = Popen([script] + arguments, \ stdout=PIPE, stderr=PIPE, \ close_fds=True, env=environ, \ universal_newlines = True, \ cwd = os.path.dirname(script)) out, err = proc.communicate() if len(err): log.error("script '%s' error output: '%s'" % (script, err[:-1])) if proc.returncode: log.error("script '%s' returned error code: %d" % (script, proc.returncode)) ret = False except (OSError,IOError) as e: log.error("script '%s' error: %s" % (script, e)) ret = False return ret def _instance_apply_static(self, instance): super(ScriptPlugin, self)._instance_apply_static(instance) self._call_scripts(instance._scripts, ["start"]) def _instance_verify_static(self, instance, ignore_missing, devices): ret = True if super(ScriptPlugin, self)._instance_verify_static(instance, ignore_missing, devices) == False: ret = False args = ["verify"] if ignore_missing: args += ["ignore_missing"] if self._call_scripts(instance._scripts, args) == True: log.info(consts.STR_VERIFY_PROFILE_OK % instance._scripts) else: log.error(consts.STR_VERIFY_PROFILE_FAIL % instance._scripts) ret = False return ret def _instance_unapply_static(self, instance, full_rollback = False): args = ["stop"] if full_rollback: args = args + ["full_rollback"] self._call_scripts(reversed(instance._scripts), args) super(ScriptPlugin, self)._instance_unapply_static(instance, full_rollback)
Save