HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_script.cpython-39.pyc
a

,�g��@sXddlmZddlmZddlZddlZddlmZm	Z	ej
��ZGdd�dej
�ZdS)�N�)�base)�Popen�PIPEcsbeZdZdZedd��Zdd�Zdd�Zdd	�Z�fd
d�Z	�fdd
�Z
ejf�fdd�	Z
�ZS)�ScriptPlugina;
	Executes an external script or binary when the profile is loaded or
	unloaded. You can choose an arbitrary executable.

	IMPORTANT: The `script` plug-in is provided mainly for compatibility
	with earlier releases. Prefer other *TuneD* plug-ins if they cover
	the required functionality.

	*TuneD* calls the executable with one of the following arguments:

	* `start` when loading the profile
	* `stop` when unloading the profile

	You need to correctly implement the `stop` action in your executable
	and revert all settings that you changed during the `start`
	action. Otherwise, the roll-back step after changing your *TuneD*
	profile will not work.

	Bash scripts can import the [filename]`/usr/lib/tuned/functions`
	Bash library and use the functions defined there. Use these
	functions only for functionality that is not natively provided
	by *TuneD*. If a function name starts with an underscore, such as
	`_wifi_set_power_level`, consider the function private and do not
	use it in your scripts, because it might change in the future.

	Specify the path to the executable using the `script` parameter in
	the plug-in configuration.

	.Running a Bash script from a profile
	====
	To run a Bash script named `script.sh` that is located in the profile
	directory, use:
	----
	[script]
	script=${i:PROFILE_DIR}/script.sh
	----
	====
	cCsddiS)N�script�)�selfrr�?/usr/lib/python3.9/site-packages/tuned/plugins/plugin_script.py�_get_config_options1s�z ScriptPlugin._get_config_optionscCsFd|_d|_|jddur<t|jdt�s.J�|jd|_ng|_dS)NTFr)Z_has_static_tuningZ_has_dynamic_tuning�options�
isinstance�list�_scripts�r	�instancerrr
�_instance_init7szScriptPlugin._instance_initcCsdS)Nrrrrr
�_instance_cleanupAszScriptPlugin._instance_cleanupc
Cs.d}|D�]}tj}|�|j���|�|�sBt�dd|�qt�d|t	|�f�t�
dt	t|�����ztt
|g|ttd|dtj�|�d�}|��\}}t|�r�t�d||dd�f�|jr�t�d	||jf�d
}Wqttf�y&}	z"t�d||	f�d
}WYd}	~	qd}	~	00q|S)NTzGPaths outside of the profile directories cannot be used in the script, zignoring script: '%s'.z'calling script '%s' with arguments '%s'zusing environment '%s')�stdout�stderrZ	close_fds�envZuniversal_newlines�cwdzscript '%s' error output: '%s'���z#script '%s' returned error code: %dFzscript '%s' error: %s)�os�environ�updateZ
_variablesZget_envZ_safe_script_path�log�error�info�str�debugr�itemsrr�path�dirnameZcommunicate�len�
returncode�OSError�IOError)
r	ZscriptsZ	arguments�retrr�proc�out�err�errr
�
_call_scriptsDs8

�

�zScriptPlugin._call_scriptscs$tt|��|�|�|jdg�dS)N�start)�superr�_instance_apply_staticr-rr��	__class__rr
r0`sz#ScriptPlugin._instance_apply_staticcstd}tt|��|||�dkr d}dg}|r4|dg7}|�|j|�dkrZt�tj|j�nt�	tj
|j�d}|S)NTFZverify�ignore_missing)r/r�_instance_verify_staticr-rrr�constsZSTR_VERIFY_PROFILE_OKrZSTR_VERIFY_PROFILE_FAIL)r	rr3Zdevicesr(�argsr1rr
r4ds��
z$ScriptPlugin._instance_verify_staticcsBdg}|tjkr|dg}|�t|j�|�tt|��||�dS)N�stopZ
full_rollback)r5Z
ROLLBACK_FULLr-�reversedrr/r�_instance_unapply_static)r	rZrollbackr6r1rr
r9ss


z%ScriptPlugin._instance_unapply_static)�__name__�
__module__�__qualname__�__doc__�classmethodrrrr-r0r4r5Z
ROLLBACK_SOFTr9�
__classcell__rrr1r
r	s'

r)Ztuned.constsr5�rZ
tuned.logsZtunedr�
subprocessrrZlogs�getrZPluginrrrrr
�<module>s