MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib/python3.12/site-packages/tuned/plugins/__pycache__/plugin_script.cpython-312.opt-1.pyc
�

�]�i����ddlmZddlmZddlZddlZddlmZm	Z	ejj�ZGd�dej�Zy)�N�)�base)�Popen�PIPEc�p��eZdZdZed��Zd�Zd�Zd�Z�fd�Z	�fd�Z
ejf�fd�	Z
�xZS)	�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
	----
	====
	c�
�ddiS)N�script�)�selfs �@/usr/lib/python3.12/site-packages/tuned/plugins/plugin_script.py�_get_config_optionsz ScriptPlugin._get_config_options1s���d�
��c�v�d|_d|_|jd�|jd|_yg|_y)NTFr
)�_has_static_tuning�_has_dynamic_tuning�options�_scripts�r�instances  r
�_instance_initzScriptPlugin._instance_init7s@�� $�(��!&�(��
���h��+� �'�'��1�8���8�rc��y)Nrrs  r
�_instance_cleanupzScriptPlugin._instance_cleanupAs��rc�l�d}|D�]q}tj}|j|jj	��|j|�stjdd|zz��jtjd|�dt|��d��tjdtt|j���z�	t|g|zttd|dtjj!|���}|j#�\}}t%|�rtjd	|�d
|dd�d��|j&r&tjd||j&fz�d
}��t|S#t(t*f$r(}	tjd	|�d|	���d
}Yd}	~	���d}	~	wwxYw)NTzGPaths outside of the profile directories cannot be used in the script, zignoring script: '%s'.zcalling script 'z' with arguments '�'zusing environment '%s')�stdout�stderr�	close_fds�env�universal_newlines�cwdzscript 'z' error output: '���z#script '%s' returned error code: %dFz	' error: )�os�environ�update�
_variables�get_env�_safe_script_path�log�error�info�str�debug�list�itemsrr�path�dirname�communicate�len�
returncode�OSError�IOError)
r�scripts�	arguments�retr
r$�proc�out�err�es
          r
�
_call_scriptszScriptPlugin._call_scriptsDsZ���#��f�
�Z�Z�7�
�>�>�$�/�/�)�)�+�,�
�
 �
 ��
(��I�I�W��&�(�)�*���8�8���Y��P�Q��9�9�
%��D�����,A�(B�
B�C���&��Y�&�
�$��'���G�G�O�O�F�#�	%�D�
���!�H�C��
�3�x��Y�Y�6�3�s��8�D�E�����Y�Y�4�����7P�P�Q��S��)�0

�*���7�
���I�I���3�4�
�C���s�
B*E<�<F3�F.�.F3c�f��tt|�|�|j|jdg�y)N�start)�superr�_instance_apply_staticr>r)rr�	__class__s  �r
rBz#ScriptPlugin._instance_apply_static`s*�����d�2�8�<����X�&�&��	�2rc�\��d}tt|�|||�dk(rd}dg}|r|dgz
}|j|j|�dk(r2t
j
tj|jz�|St
jtj|jz�d}|S)NTF�verify�ignore_missing)rAr�_instance_verify_staticr>rr)r+�consts�STR_VERIFY_PROFILE_OKr*�STR_VERIFY_PROFILE_FAIL)rrrF�devicesr9�argsrCs      �r
rGz$ScriptPlugin._instance_verify_staticds�����#�
�<��6�x��G�� %�&�	�3�
��$������4�	����)�)�4�0�D�8��8�8�F�(�(�8�+<�+<�<�=�

�*��9�9�V�
+�
+�h�.?�.?�
?�@�	�3�	�*rc���dg}|tjk(r|dgz}|jt|j�|�t
t|�||�y)N�stop�
full_rollback)rH�
ROLLBACK_FULLr>�reversedrrAr�_instance_unapply_static)rr�rollbackrLrCs    �r
rRz%ScriptPlugin._instance_unapply_staticssQ���
��$�
��%�%�%�
�/�"�
"�4����X�h�/�/�0�$�7���d�4�X�x�Hr)�__name__�
__module__�__qualname__�__doc__�classmethodrrrr>rBrGrH�
ROLLBACK_SOFTrR�
__classcell__)rCs@r
rr	sN���%�N����
��
�83�

�:@�9M�9M�I�Irr)�tuned.constsrH�r�
tuned.logs�tunedr#�
subprocessrr�logs�getr)�Pluginrrrr
�<module>rcs8�����	�"��j�j�n�n���oI�4�;�;�oIr