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/admin/__pycache__/admin.cpython-312.pyc
�

�]�i�?���ddlmZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlZddlZddlZddlZddlZddlZGd	�d
e�Zy)�)�print_functionN)�commands)�Locator�)�TunedAdminDBusException)�TunedException)�ProfileRecommenderc�r�eZdZdddejejfd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd5d�Zd5d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d"�Z&d#�Z'd$�Z(d%�Z)d&�Z*d'�Z+d(�Z,d)�Z-d6d*�Z.d6d+�Z/d7d,�Z0d7d-�Z1d.�Z2d/�Z3d0�Z4d1�Z5d2�Z6d3�Z7y4)8�AdminTFc�r�||_||_||_||_t	|�|_t
|�|_tj�|_
d|_d|_d|_
d|_d|_||_t#�|_|jr|j'�|_yd|_y)N�TF)�_dbus�_debug�_async�_timeoutr�_cmd�profiles_locator�_profiles_locator�	threading�Event�_daemon_action_finished�_daemon_action_profile�_daemon_action_result�_daemon_action_errstr�_controller�
_log_token�
_log_levelr	�_profile_recommender�
_init_dbus�
_dbus_working)�self�profile_dirs�dbus�debug�asynco�timeout�	log_levels       �6/usr/lib/python3.12/site-packages/tuned/admin/admin.py�__init__zAdmin.__init__s����$�*��$�+��$�+��$�-��u�o�$�)�+�L�9�$��!*���!2�$�� "�$��#�$��!�$���$���$�/��$�/�0�2�$��,0�J�J�t���(�$��E�$��c�r�tjjtjtj
tj|j�|_	|jjtj|j�y#t$r}|j|�Yd}~yd}~wwxYw�NTF)�tuned�admin�DBusController�consts�DBUS_BUS�DBUS_INTERFACE�DBUS_OBJECTrr�set_signal_handler�SIGNAL_PROFILE_CHANGED�_signal_profile_changed_cbr�_error�r!�es  r(rzAdmin._init_dbus%s���[�[�/�/�����AV�AV�X^�Xj�Xj�lp�lw�lw�x�$������&�&�v�'D�'D�d�Fe�Fe�f�
��	 ���;�;�q�>�
���s�4B�	B6�B1�1B6c�:�t|tj��y)N)�file)�print�sys�stderr)r!�messages  r(r7zAdmin._error.s����c�j�j�!r*c��|jj�s0||_||_||_|jj�yy�N)r�is_setrrr�set)r!�profile_name�result�errstrs    r(r6z Admin._signal_profile_changed_cb1sC��	
�	%�	%�	,�	,�	.�!-�4�� &�4�� &�4�����#�#�%�	
/r*c�&�	tjt|jj	t
j��d�y#t$r'}|jtjk(cYd}~Sd}~wttf$r
}Yd}~yd}~wwxYw)NrFT)�os�kill�intr�	read_filer0�PID_FILE�OSError�errno�EPERM�
ValueError�IOErrorr8s  r(�_tuned_is_runningzAdmin._tuned_is_running9sh����7�7�3�t�y�y�"�"�6�?�?�3�4�a�8�

��	
�!�
�'�'�U�[�[�
 � ��
�g�	��
���s$�AA	�		B�A4�.B�4B�Bc��|�|dk(ryd}d}d}	t|d|z�}	t|d|z�}|jr`	|j
j
|j�|j
j|g|��i|��|j
j�}|js||i|��}|S#t$r}d|_Yd}~��d}~wwxYw#t$r;}|js%|jt	|�d|zz�Yd}~yYd}~��d}~wwxYw#t$r"}|j|�d|_Yd}~��d}~wwxYw)Nr
F�
_action_dbus_�_action_z , action '%s' is not implemented)�getattr�AttributeErrorr r7�strr�set_on_exit_action�_log_capture_finish�
set_action�runr)r!�action_name�args�kwargs�action�action_dbus�resr9s        r(r`zAdmin.actionCsN����K�2�-�
��&��+�
�#������<�=�;���D�*�{�2�3�6�

�������'�'�
��� ��D������=�d�=�f�=�
�
�
�
�
�
 �C�

�	�	�	��	 ��	 �3�	�*��)
���4������
��
�
�
��K�K��A��;�k�I�I�J������"���K�K��N��D�����sF�B1�C�AD�1	C�:C�C�	D�,D
�
D�	E�D;�;Ec
���td�|D]S}|d�;|ddk7r3t|jjd|dzdd|dz���Ctd|dz��Uy)NzAvailable profiles:rr
z- %sr�)r<r�	align_str)r!�
profile_names�profiles   r(�_print_profileszAdmin._print_profilesash������g�
�a�j�����r�!1�	�$�)�)�
�
�f�w�q�z�1�2�v���
�7J�
K�L�	�&�7�1�:�
��	r*c�:�	|jj�}|j	|�|j�|jj
d�S#t$r9}|jj�D�cgc]}|df��ncc}w}}Yd}~�yd}~wwxYw�Nr
T)r�	profiles2r�profilesrh�_action_dbus_active�exit)r!rfr9rgs    r(�_action_dbus_list_profilesz Admin._action_dbus_list_profilesis���N��#�#�-�-�/�=����}�%�����	
�	�	�	�	�t�	$�$��
!�N�15�1A�1A�1J�1J�1L�M�1L�g�W�b�M�1L��M�=�M��N�s#�A�	B�!B�=B	�B�Bc�v�|j|jj��|j�y�NT)rhr�get_known_names_summary�_action_active�r!s r(�_action_list_profileszAdmin._action_list_profilesss.�����t�-�-�E�E�G�H�����	
r*c�~�|jj�}|dk(rd}|jjd�|Srj)r�active_profilern�r!rDs  r(�_dbus_get_active_profilezAdmin._dbus_get_active_profilexs=���!�!�0�0�2�,��R���<��������	�r*c�@�|jj�\}}|SrA)r�get_active_profile)r!rD�manuals   r(�_get_active_profilezAdmin._get_active_profiles�����5�5�7��,��	�r*c��|jj�\}}|�|du}|rtjStjSrA)rr{r0�ACTIVE_PROFILE_MANUAL�ACTIVE_PROFILE_AUTO)r!rgr|s   r(�_get_profile_modezAdmin._get_profile_mode�sA���i�i�2�2�4��7�F��^��4��6�)/��	%�	%�O�V�5O�5O�Or*c�H�|jj�}|dk(rd}|S)Nr
)r�post_loaded_profilerxs  r(�_dbus_get_post_loaded_profilez#Admin._dbus_get_post_loaded_profile�s)���!�!�5�5�7�,��R���<�	�r*c�:�|jj�}|SrA)r�get_post_loaded_profilerxs  r(�_get_post_loaded_profilezAdmin._get_post_loaded_profile�s�����2�2�4�,�	�r*c���|ddk(r`td�t|d�t�td�t|d�t�td�t|d�ytd	|z�y
)NrTz
Profile name:rzProfile summary:�zProfile description:�z,Unable to get information about profile '%s'F�r<)r!rg�profile_infos   r(�_print_profile_infozAdmin._print_profile_info�sj���!�_��������a����7��	����a����7��	� ���a���
��	7�'�	A�B�
r*c���|dk(r|j�}|r,|j||jj|��}n
t	d�d}|jj|�S�Nr
�No current active profile.F)ryr�rr�r<rn)r!rgrbs   r(�_action_dbus_profile_infozAdmin._action_dbus_profile_info�sb����]�
�
*�
*�
,�7��	
�	!�	!�'�4�+;�+;�+H�+H��+Q�	R�3��	%�&�	�3�	
�	�	�	�	�s�	#�#r*c	�F�|dk(r 	|j�}|�td�y	|j||jj|tjtjgddg��S#t$r$}|jt	|��Yd}~yd}~wwxYwr�)r}r<rr7rXr�r�get_profile_attrsr0�PROFILE_ATTR_SUMMARY�PROFILE_ATTR_DESCRIPTION)r!rgr9s   r(�_action_profile_infozAdmin._action_profile_info�s�����]���&�&�(�G���
�'�(���
�	!�	!�'�4�+A�+A�+S�+S�T[�^d�^y�^y�|B�|[�|[�^\�_a�ce�^f�,g�
h�h�����K�K��A������s�A3�3	B �<B�B c�<�|�td�ytd|z�y)Nr�FzCurrent active profile: %sTr�rxs  r(�_print_profile_namezAdmin._print_profile_name�s%�����	%�&�
��	%��	4�5�	
r*c�&�|rtd|z�yy)NzCurrent post-loaded profile: %sr�rxs  r(�_print_post_loaded_profilez Admin._print_post_loaded_profile�s����	*�\�	9�:�r*c��|j�}|j|�}|r!|j�}|j|�|jj|�SrA)ryr�r�r�rrn)r!rwrbr�s    r(rmzAdmin._action_dbus_active�sX���0�0�2�.�� � ��0�#���;�;�=���"�"�#6�7�	
�	�	�	�	�s�	#�#r*c��	|j�}|j�}|r|r|dz
}nd}||z
}|�:|j�s*t
d�t
d|z�|rt
d|z�y|j|�}|j|�|S#t$r$}|jt	|��Yd}~yd}~wwxYw)N� r
FzKIt seems that tuned daemon is not running, preset profile is not activated.zPreset profile: %szPreset post-loaded profile: %sT)	r}r�rr7rXrRr<r�r�)r!rDr�r9rbs     r(rszAdmin._action_active�s���
��*�*�,�<��6�6�8�����S��\��\��'�'�L���d�&<�&<�&>��	V�W��	��	,�-��	�
*�-@�
@�A�
�� � ��.�#��!�!�"5�6�	�*��
���;�;�s�1�v��
���s�1B�	C�B;�;Cc� �td|z�y)NzProfile selection mode: r�)r!�modes  r(�_print_profile_modezAdmin._print_profile_mode�s���"�T�)�*r*c��|jj�\}}|j|�|dk7r,|j|�|jj	d�S|jj	d�S)Nr
FT)r�profile_moder�r7rn)r!r��errors   r(�_action_dbus_profile_modezAdmin._action_dbus_profile_mode�si��� � �-�-�/�+�$�����4� �
�b�[��;�;�u��
�
�
�
�
��
&�&�	
�	�	�	�	�t�	$�$r*c��	|j�}|j|�y#t$r$}|jt	|��Yd}~yd}~wwxYwr,)r�r�rr7rX)r!r�r9s   r(�_action_profile_modezAdmin._action_profile_mode�sI���
�
 �
 �
"�4����D�!�
��	���;�;�s�1�v��
���s�!$�	A�A�Ac���|rI|jj�s-|jj�s|jd�d}|S|jd|z�|S)NzCannot enable the tuning.FzUnable to switch profile: %s)r�
is_running�startr7�r!�ret�msgs   r(�_profile_print_statuszAdmin._profile_print_status�sZ���
�
�
�
%�
%�
'��0@�0@�0F�0F�0H��K�K�+�,�
�C�

�*��;�;�-��3�4�	�*r*c���tj�|j|jzk\r3td|jz�|jjd�S|jj�ri|j|k(rZ|js3td|jz�|jjd�S|jjd�Sy)Nz�Operation timed out after waiting %d seconds(s), you may try to increase timeout by using --timeout command line option or using --async.FzError changing profile: %sT)�time�
_timestamprr<rrnr�isSetrrrrxs  r(�_action_dbus_wait_profilezAdmin._action_dbus_wait_profiles���	�Y�Y�[�D�O�O�d�m�m�3�3��
U�X\�Xe�Xe�
e�f�
�
�
�
�
��
&�&�	�!�!�'�'�)�
�!�!�\�1��%�%�
�'�$�*D�*D�D�E����!�!�%�(�(���� � ��&�&�	r*c�X�|j�|jdk(ry	|jj|j�}d|_t|dtj
��tj
j
�y#t$r}|jd�Yd}~yd}~wwxYw)Nr
)�endr;zUError: Failed to stop log capture. Restart the TuneD daemon to prevent a memory leak.)	rr�log_capture_finishr<r=r>�flushrr7)r!�log_msgsr9s   r(rZzAdmin._log_capture_finishs���	�_�_�����2� 5�	�h����1�1�	�_�_��8��4�?����C�J�J�/��:�:�����	 �h��;�;�f�g�g��h�s�A&B�	B)�B$�$B)c���t|�dk(r|j�Sdj|�}|dk(r|jj	d�S|j
j
�|jsI|j�=|jdzdz}|jj|j|�|_|jj|�\}}|js|s+|jj	|j||��Stj�|_|jj!|j"|�|j||�S)Nrr�r
F��)�len�_action_dbus_list�joinrrnr�clearrrr�log_capture_startr�switch_profiler�r�r�r[r�)r!rlrDr&r�r�s      r(�_action_dbus_profilezAdmin._action_dbus_profiles#����]�a��
�
 �
 �
"�"����(�#�,��R��
�
�
�
�
��
&�&����$�$�&�	
������4�
�]�]�R�
�!�
#�7��%�%�7�7�	�_�_�g��4�?����.�.�|�<�*�3��	�[�[��
�
�
�
�
�� :� :�3�� D�
E�E��Y�Y�[�4�?������t�=�=�|�L�	
�	#�	#�C��	-�-r*c��td�|jjgd��\}}|dk7rtd��td�y)NzTrying to (re)start tuned...)�servicer-�restartrz5TuneD (re)start failed, check TuneD logs for details.zTuneD (re)started.)r<r�executerr�s   r(�_restart_tunedzAdmin._restart_tuned.s@���&�'��y�y� � �!@�A�*�3���A�X�	�O�	P�P���r*c���||jj�vrw	|jr2|j�|j	�r|j|g�S|jj||�|j�td�y|jd|z�y#t$r5}|jt|��|jd�Yd}~yd}~wwxYw)Nz[TuneD is not active on the DBus, not checking whether the profile was successfully applied.TzUnable to switch profile.Fz%Requested profile '%s' doesn't exist.)r�get_known_namesrr�rr�r�save_active_profiler<rr7rX)r!rDr|r9s    r(�_set_profilezAdmin._set_profile5s����T�+�+�;�;�=�=���z�z�	��������
�
&�
&��~�
6�6��I�I�!�!�,��7�����	�
g�h���;�;�6��E�F�
��
���K�K��A����K�K�+�,����s�=B)�7B)�)	C'�2+C"�"C'c��t|�dk(r|j�Sdj|�}|dk(ry|j|d�S)Nrr�r
FT)r�rur�r�)r!rlrDs   r(�_action_profilezAdmin._action_profileHsI����]�a��
�
$�
$�
&�&����(�#�,��R��
�	
�	�	�<��	.�.r*c�b�|jj�}|jj�|jsI|j
�=|jdzdz}|jj|j
|�|_|jj�\}}|js|s+|jj|j||��Stj�|_
|jj|j|�|j||�S)Nr�r�)r�recommend_profilerr�rrrr�r�auto_profilernr�r�r�r[r�)r!rDr&r�r�s     r(�_action_dbus_auto_profilezAdmin._action_dbus_auto_profilePs����!�!�3�3�5�,����$�$�&�	
������4�
�]�]�R�
�!�
#�7��%�%�7�7�	�_�_�g��4�?����,�,�.�*�3��	�[�[��
�
�
�
�
�� :� :�3�� D�
E�E��Y�Y�[�4�?������t�=�=�|�L�	
�	#�	#�C��	-�-r*c�Z�|jj�}|j|d�S)NF)r�	recommendr�rxs  r(�_action_auto_profilezAdmin._action_auto_profile`s)���*�*�4�4�6�,�	
�	�	�<��	/�/r*c�~�t|jj��|jjd�Srq)r<rr�rnrts r(�_action_dbus_recommend_profilez$Admin._action_dbus_recommend_profileds0������*�*�,�-�	
�	�	�	�	�t�	$�$r*c�J�t|jj��yrq)r<rr�rts r(�_action_recommend_profilezAdmin._action_recommend_profilehs����!�!�+�+�-�.�	
r*c�~�|r|jj�}n|jj�}|rtd�nBtd�td�td�td�td�td�tdtj
z�|jj
|�S)	NzIVerification succeeded, current system settings match the preset profile.zLVerification failed, current system settings differ from the preset profile.z=You can mostly fix this by restarting the TuneD daemon, e.g.:z  systemctl restart tuned�orz  service tuned restartzNSometimes (if some plugins like bootloader are used) a reboot may be required.z&See TuneD log file ('%s') for details.)r�verify_profile_ignore_missing�verify_profiler<r0�LOG_FILErn)r!�ignore_missingr�s   r(�_action_dbus_verify_profilez!Admin._action_dbus_verify_profilels����	
�	�	�	7�	7�	9�3�	
�	�	�	(�	(�	*�3���	T�U��	W�X��	H�I��	$�%���;��	"�#��	Y�Z��0�6�?�?�B�C�	
�	�	�	�	�s�	#�#r*c��td�y�Nz Not supported in no_daemon mode.Fr�)r!r�s  r(�_action_verify_profilezAdmin._action_verify_profile}����*�+�	r*c���d}|jj|j|�|_|jj	�}|s|jd�|jj
|�S)NrdzCannot disable active profile.)rr�rr�offr7rn)r!r&r�s   r(�_action_dbus_offzAdmin._action_dbus_off�sc���'��$�$�6�6��O�O�W��$�/�������#�	��;�;�/�0�	
�	�	�	�	�s�	#�#r*c��td�yr�r�rts r(�_action_offzAdmin._action_off�r�r*c�\�|dk(r|j�S|dk(r|j|��Sy)aDPrint accessible profiles or plugins got from TuneD dbus api

		Keyword arguments:
		list_choice -- argument from command line deciding what will be listed
		verbose -- if True then list plugin's config options and their hints
			if possible. Functional only with plugin listing, with profiles
			this argument is omitted
		rl�plugins��verboseN)ro�_action_dbus_list_plugins�r!�list_choicer�s   r(r�zAdmin._action_dbus_list�s<���J��
�
)�
)�
+�+��i��
�
(�
(��
(�
9�9� r*c�\�|dk(r|j�S|dk(r|j|��Sy)aaPrint accessible profiles or plugins with no daemon mode

		Keyword arguments:
		list_choice -- argument from command line deciding what will be listed
		verbose -- Plugins cannot be listed in this mode, so verbose argument
			is here only because argparse module always supplies verbose
			option and if verbose was not here it would result in error
		rlr�r�N)ru�_action_list_pluginsr�s   r(�_action_listzAdmin._action_list�s<���J��
�
$�
$�
&�&��i��
�
#�
#�G�
#�
4�4� r*c��|jj�}|j�D]w}t|�|rt	||�dk(r�"|jj|�}||D]3}td|z�|j
|d�}|s�&td|z��5�y|jjd�S)zvPrint accessible plugins

		Keyword arguments:
		verbose -- if is set to True then parameters and hints are printed
		rz	%sNz		%sT)r�get_plugins�keysr<r��get_plugin_hints�getrn)r!r�r��plugin�hints�	parameter�hints       r(r�zAdmin._action_dbus_list_plugins�s���
���(�(�*�'�����f���=�
�S����)�Q�.�����,�,�V�4�5��F�O�y�	�&�9�
���9�9�Y��%�D��
�8�d���	$��
�	�	�	�	�t�	$�$r*c��td�yr�r�)r!r�s  r(r�zAdmin._action_list_plugins�r�r*c��|jj||�\}}|s|jd|z�|jj|�S)NzUnable to acquire devices: %s)r�instance_acquire_devicesr7rn)r!�devices�instancer�r�s     r(�%_action_dbus_instance_acquire_devicesz+Admin._action_dbus_instance_acquire_devices�sJ�����8�8��(�K�*�3��	��;�;�.��4�5�	
�	�	�	�	�s�	#�#r*c��td�yr�r�)r!r�r�s   r(� _action_instance_acquire_devicesz&Admin._action_instance_acquire_devices�r�r*c��|jj|�\}}}|s/|jd|z�|jjd�S|D]\}}t	|�d|�d���|jjd�S)NzUnable to list instances: %sFz (�)T)r�
get_instancesr7rnr<)r!�plugin_namer�r��pairsr�r�s       r(�_action_dbus_get_instancesz Admin._action_dbus_get_instances�s~���&�&�4�4�[�A��3��U�	��;�;�-��3�4�
�
�
�
�
��
&�&���h���h��	'�(� �	
�	�	�	�	�t�	$�$r*c��td�yr�r�)r!rs  r(�_action_get_instanceszAdmin._action_get_instances�r�r*c��|jj|�\}}}|s/|jd|z�|jjd�S|D]
}t	|��|jjd�S)NzUnable to list devices: %sFT)r�instance_get_devicesr7rnr<)r!r�r�r�r��devices      r(�!_action_dbus_instance_get_devicesz'Admin._action_dbus_instance_get_devices�ss���(�(�=�=�h�G��3��W�	��;�;�+�c�1�2�
�
�
�
�
��
&�&��f���=��	
�	�	�	�	�t�	$�$r*c��td�yr�r�)r!r�s  r(�_action_instance_get_devicesz"Admin._action_instance_get_devices�r�r*N)r
)rlF)F)8�__name__�
__module__�__qualname__r0�
ADMIN_TIMEOUT�logging�ERRORr)rr7r6rRr`rhroruryr}r�r�r�r�r�r�r�r�rmrsr�r�r�r�r�rZr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rr�r*r(rrs��)-�u��V�1�1��}�}�B�&�"�&��
�<�%��
��P���
�$�
h��;�$�
�2+�%��
�
�
h�.�(��&/�.� 0�%��$�"�$��:�5�%�&�$��%��%�r*r)�
__future__r�tuned.adminr-�tuned.utils.commandsr�tuned.profilesrr�
exceptionsr�tuned.exceptionsr�tuned.constsr0�tuned.utils.profile_recommenderr	rHr=rNr�rr�objectrrr*r(�<module>r!s=��%��)�6�/�+��>�	�
�����S�F�Sr*