JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_script.cpython-39.opt-1.pyc

a

���h��@sXddlmZddlmZddlZddlZddlmZm	Z	ej
��ZGdd�dej
�ZdS)�N�)�base)�Popen�PIPEcsbeZdZdZedd��Zdd�Zdd�Zdd	�Z�fd
d�Z	�fdd
�Z
ejf�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_optionscCs2d|_d|_|jddur(|jd|_ng|_dS)NTFr)Z_has_static_tuningZ_has_dynamic_tuning�options�_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�debug�list�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,r
r��	__class__rr
r/`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,r
rr�constsZSTR_VERIFY_PROFILE_OKrZSTR_VERIFY_PROFILE_FAIL)r	rr2Zdevicesr'�argsr0rr
r3ds��
z$ScriptPlugin._instance_verify_staticcsBdg}|tjkr|dg}|�t|j�|�tt|��||�dS)N�stopZ
full_rollback)r4Z
ROLLBACK_FULLr,�reversedr
r.r�_instance_unapply_static)r	rZrollbackr5r0rr
r8ss


z%ScriptPlugin._instance_unapply_static)�__name__�
__module__�__qualname__�__doc__�classmethodrrrr,r/r3r4Z
ROLLBACK_SOFTr8�
__classcell__rrr0r
r	s'

r)Ztuned.constsr4�rZ
tuned.logsZtunedr�
subprocessrrZlogs�getrZPluginrrrrr
�<module>s

Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2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