403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/tuned/admin/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/tuned/admin/__pycache__/admin.cpython-39.pyc
a

,�g�?�@s�ddlmZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlZddlZddlZddlZddlZddlZGd	d
�d
e�ZdS)�)�print_functionN)�commands)�Locator�)�TunedAdminDBusException)�TunedException)�ProfileRecommenderc@s�eZdZdddejejfdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zdhd"d#�Zdid$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z d8d9�Z!d:d;�Z"d<d=�Z#d>d?�Z$d@dA�Z%dBdC�Z&dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,dPdQ�Z-djdSdT�Z.dkdUdV�Z/dldWdX�Z0dmdYdZ�Z1d[d\�Z2d]d^�Z3d_d`�Z4dadb�Z5dcdd�Z6dedf�Z7dgS)n�AdminTFcCsz||_||_||_||_t|�|_t|�|_t�	�|_
d|_d|_d|_
d|_d|_||_t�|_|jrp|��nd|_dS)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)�selfZprofile_dirsZdbus�debugZasynco�timeoutZ	log_level�r!�5/usr/lib/python3.9/site-packages/tuned/admin/admin.py�__init__s


zAdmin.__init__c
Csjtj�tjtjtj|j�|_z|j�	tj
|j�WdStyd}z|�
|�WYd}~dSd}~00dS�NTF)�tunedZadminZDBusController�constsZDBUS_BUSZDBUS_INTERFACEZDBUS_OBJECTrrZset_signal_handlerZSIGNAL_PROFILE_CHANGED�_signal_profile_changed_cbr�_error�r�er!r!r"r%s
zAdmin._init_dbuscCst|tjd�dS)N)�file)�print�sys�stderr)r�messager!r!r"r(.szAdmin._errorcCs*|j��s&||_||_||_|j��dS�N)r�is_setrrr�set)r�profile_name�resultZerrstrr!r!r"r'1s

z Admin._signal_profile_changed_cbc
Cs|zt�t|j�tj��d�WnXtyN}z|jtj	kWYd}~Sd}~0t
tfyv}zWYd}~dSd}~00dS)NrFT)�os�kill�intrZ	read_filer&ZPID_FILE�OSError�errno�EPERM�
ValueError�IOErrorr)r!r!r"�_tuned_is_running9s zAdmin._tuned_is_runningc
OsP|dus|dkrdSd}d}d}zt|d|�}Wn*ty\}zd|_WYd}~n
d}~00zt|d|�}WnNty�}z6|js�|�t|�d|�WYd}~dSWYd}~n
d}~00|j�r6z6|j�|j�|jj|g|�Ri|��|j�	�}Wn6t
�y4}z|�|�d|_WYd}~n
d}~00|j�sL||i|��}|S)Nr
FZ
_action_dbus_Z_action_z , action '%s' is not implemented)�getattr�AttributeErrorrr(�strrZset_on_exit_action�_log_capture_finish�
set_action�runr)r�action_name�args�kwargs�actionZaction_dbus�resr*r!r!r"rGCs8$�
zAdmin.actionc	Csdtd�|D]R}|ddurN|ddkrNt|j�d|ddd|d��qtd|d�qdS)NzAvailable profiles:rr
z- %sr�)r,rZ	align_str)r�
profile_names�profiler!r!r"�_print_profilesas
&zAdmin._print_profilesc
Csfz|j��}Wn8tyF}z dd�|j��D�}WYd}~n
d}~00|�|�|��|j�d�S)NcSsg|]}|df�qS)r
r!)�.0rKr!r!r"�
<listcomp>n�z4Admin._action_dbus_list_profiles.<locals>.<listcomp>T)rZ	profiles2r�profilesrL�_action_dbus_active�exit)rrJr*r!r!r"�_action_dbus_list_profilesis*
z Admin._action_dbus_list_profilescCs|�|j���|��dS�NT)rLrZget_known_names_summary�_action_active�rr!r!r"�_action_list_profilessszAdmin._action_list_profilescCs&|j��}|dkrd}|j�d�|S)Nr
T)r�active_profilerR�rr3r!r!r"�_dbus_get_active_profilexs

zAdmin._dbus_get_active_profilecCs|j��\}}|Sr0)r�get_active_profile)rr3�manualr!r!r"�_get_active_profileszAdmin._get_active_profilecCs.|j��\}}|dur|du}|r(tjStjSr0)rr[r&ZACTIVE_PROFILE_MANUALZACTIVE_PROFILE_AUTO)rrKr\r!r!r"�_get_profile_mode�szAdmin._get_profile_modecCs|j��}|dkrd}|S)Nr
)r�post_loaded_profilerYr!r!r"�_dbus_get_post_loaded_profile�s
z#Admin._dbus_get_post_loaded_profilecCs|j��}|Sr0)rZget_post_loaded_profilerYr!r!r"�_get_post_loaded_profile�s
zAdmin._get_post_loaded_profilecCsl|ddkrXtd�t|d�t�td�t|d�t�td�t|d�dStd	|�d
SdS)NrTz
Profile name:rzProfile summary:�zProfile description:�z,Unable to get information about profile '%s'F�r,)rrK�profile_infor!r!r"�_print_profile_info�szAdmin._print_profile_infor
cCsB|dkr|��}|r*|�||j�|��}ntd�d}|j�|�S�Nr
�No current active profile.F)rZrfrrer,rR)rrKrHr!r!r"�_action_dbus_profile_info�szAdmin._action_dbus_profile_infoc
Cs�|dkr`z"|��}|dur(td�WdSWn4ty^}z|�t|��WYd}~dSd}~00|�||j�|tj	tj
gddg��Srg)r]r,rr(r@rfrZget_profile_attrsr&ZPROFILE_ATTR_SUMMARYZPROFILE_ATTR_DESCRIPTION)rrKr*r!r!r"�_action_profile_info�s
zAdmin._action_profile_infocCs$|durtd�dStd|�dS)NrhFzCurrent active profile: %sTrdrYr!r!r"�_print_profile_name�s
zAdmin._print_profile_namecCs|rtd|�dS)NzCurrent post-loaded profile: %srdrYr!r!r"�_print_post_loaded_profile�sz Admin._print_post_loaded_profilecCs4|��}|�|�}|r(|��}|�|�|j�|�Sr0)rZrkr`rlrrR)rrXrHr_r!r!r"rQ�s

zAdmin._action_dbus_activec
Cs�z2|��}|��}|r0|r$|d7}nd}||7}Wn4tyf}z|�t|��WYd}~dSd}~00|dur�|��s�td�td|�|r�td|�dS|�|�}|�|�|S)N� r
FzKIt seems that tuned daemon is not running, preset profile is not activated.zPreset profile: %szPreset post-loaded profile: %sT)	r]rarr(r@r=r,rkrl)rr3r_r*rHr!r!r"rU�s(


zAdmin._action_activecCstd|�dS)NzProfile selection mode: rd)r�moder!r!r"�_print_profile_mode�szAdmin._print_profile_modecCsB|j��\}}|�|�|dkr6|�|�|j�d�S|j�d�S)Nr
FT)rZprofile_moderor(rR)rrn�errorr!r!r"�_action_dbus_profile_mode�s

zAdmin._action_dbus_profile_modec
CsRz|��}|�|�WdStyL}z|�t|��WYd}~dSd}~00dSr$)r^rorr(r@)rrnr*r!r!r"�_action_profile_mode�s
zAdmin._action_profile_modecCs:|r(|j��s6|j��s6|�d�d}n|�d|�|S)NzCannot enable the tuning.FzUnable to switch profile: %s)rZ
is_running�startr(�r�ret�msgr!r!r"�_profile_print_status�s
zAdmin._profile_print_statuscCsrt��|j|jkr.td|j�|j�d�S|j��rn|j|krn|j	sbtd|j
�|j�d�S|j�d�SdS)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,rrRr�isSetrrrrYr!r!r"�_action_dbus_wait_profiles

zAdmin._action_dbus_wait_profilec
Cs~|jdus|jdkrdSz2|j�|j�}d|_t|dtjd�tj��Wn.tyx}z|�d�WYd}~n
d}~00dS)Nr
)�endr+zUError: Failed to stop log capture. Restart the TuneD daemon to prevent a memory leak.)	rrZlog_capture_finishr,r-r.�flushrr()rZlog_msgsr*r!r!r"rAs�zAdmin._log_capture_finishcCs�t|�dkr|��Sd�|�}|dkr2|j�d�S|j��|jsl|jdurl|j	dd}|j�
|j|�|_|j�|�\}}|js�|s�|j�|�
||��St��|_|j�|j|�|�
||�S)Nrrmr
F��)�len�_action_dbus_list�joinrrRr�clearr
rr�log_capture_startrZswitch_profilerwrxryrBr{)rrPr3r rurvr!r!r"�_action_dbus_profiles"

�

zAdmin._action_dbus_profilecCs8td�|j�gd��\}}|dkr,td��td�dS)NzTrying to (re)start tuned...)Zservicer%Zrestartrz<TuneD (re)start failed, you need to (re)start TuneD by hand.zTuneD (re)started.)r,rZexecuterrtr!r!r"�_restart_tuned.s
zAdmin._restart_tunedc
Cs�||j��vr�zH|jr4|��|��r4|�|g�WS|j�||�|��td�WdSt	y�}z&|�
t|��|�
d�WYd}~dSd}~00n|�
d|�dSdS)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.)rZget_known_namesrr�rr�rZsave_active_profiler,rr(r@)rr3r\r*r!r!r"�_set_profile5s 
zAdmin._set_profilecCs6t|�dkr|��Sd�|�}|dkr*dS|�|d�S)Nrrmr
FT)r�rWr�r�)rrPr3r!r!r"�_action_profileHs
zAdmin._action_profilecCs�|j��}|j��|jsD|jdurD|jdd}|j�|j|�|_|j�	�\}}|js\|sp|j�
|�||��St��|_
|j�|j|�|�||�S)Nr~r)r�recommend_profilerr�r
rrr�rZauto_profilerRrwrxryrBr{)rr3r rurvr!r!r"�_action_dbus_auto_profilePs

�

zAdmin._action_dbus_auto_profilecCs|j��}|�|d�S)NF)r�	recommendr�rYr!r!r"�_action_auto_profile`s
zAdmin._action_auto_profilecCst|j���|j�d�SrT)r,rr�rRrVr!r!r"�_action_dbus_recommend_profiledsz$Admin._action_dbus_recommend_profilecCst|j���dSrT)r,rr�rVr!r!r"�_action_recommend_profilehszAdmin._action_recommend_profilecCsr|r|j��}n
|j��}|r(td�n0td�td�td�td�td�td�tdtj�|j�|�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.)rZverify_profile_ignore_missingZverify_profiler,r&ZLOG_FILErR)r�ignore_missingrur!r!r"�_action_dbus_verify_profilels

z!Admin._action_dbus_verify_profilecCstd�dS�Nz Not supported in no_daemon mode.Frd)rr�r!r!r"�_action_verify_profile}szAdmin._action_verify_profilecCs:d}|j�|j|�|_|j��}|s.|�d�|j�|�S)NrIzCannot disable active profile.)rr�rrZoffr(rR)rr rur!r!r"�_action_dbus_off�s�

zAdmin._action_dbus_offcCstd�dSr�rdrVr!r!r"�_action_off�szAdmin._action_offrPcCs(|dkr|��S|dkr$|j|d�SdS)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
		rP�plugins��verboseN)rS�_action_dbus_list_plugins�rZlist_choicer�r!r!r"r��s	zAdmin._action_dbus_listcCs(|dkr|��S|dkr$|j|d�SdS)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
		rPr�r�N)rW�_action_list_pluginsr�r!r!r"�_action_list�s	zAdmin._action_listcCs�|j��}|��D]d}t|�|rt||�dkr4q|j�|�}||D],}td|�|�|d�}|rHtd|�qHq|j�d�S)zvPrint accessible plugins

		Keyword arguments:
		verbose -- if is set to True then parameters and hints are printed
		rz	%sNz		%sT)rZget_plugins�keysr,r�Zget_plugin_hints�getrR)rr�r��plugin�hintsZ	parameter�hintr!r!r"r��s
zAdmin._action_dbus_list_pluginscCstd�dSr�rd)rr�r!r!r"r��szAdmin._action_list_pluginscCs0|j�||�\}}|s$|�d|�|j�|�S)NzUnable to acquire devices: %s)rZinstance_acquire_devicesr(rR)r�devices�instancerurvr!r!r"�%_action_dbus_instance_acquire_devices�sz+Admin._action_dbus_instance_acquire_devicescCstd�dSr�rd)rr�r�r!r!r"� _action_instance_acquire_devices�sz&Admin._action_instance_acquire_devicescCsZ|j�|�\}}}|s0|�d|�|j�d�S|D]\}}td||f�q4|j�d�S)NzUnable to list instances: %sFz%s (%s)T)rZ
get_instancesr(rRr,)r�plugin_namerurv�pairsr�r�r!r!r"�_action_dbus_get_instances�sz Admin._action_dbus_get_instancescCstd�dSr�rd)rr�r!r!r"�_action_get_instances�szAdmin._action_get_instancescCsN|j�|�\}}}|s0|�d|�|j�d�S|D]}t|�q4|j�d�S)NzUnable to list devices: %sFT)rZinstance_get_devicesr(rRr,)rr�rurvr�Zdevicer!r!r"�!_action_dbus_instance_get_devices�s
z'Admin._action_dbus_instance_get_devicescCstd�dSr�rd)rr�r!r!r"�_action_instance_get_devices�sz"Admin._action_instance_get_devicesN)r
)r
)rPF)rPF)F)F)8�__name__�
__module__�__qualname__r&Z
ADMIN_TIMEOUT�loggingZERRORr#rr(r'r=rGrLrSrWrZr]r^r`rarfrirjrkrlrQrUrorqrrrwr{rAr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r!r!r!r"r	sh�
	




		




		r	)Z
__future__rZtuned.adminr%Ztuned.utils.commandsrZtuned.profilesrr�
exceptionsrZtuned.exceptionsrZtuned.constsr&Ztuned.utils.profile_recommenderrr5r-r9rxrr��objectr	r!r!r!r"�<module>s

Youez - 2016 - github.com/yon3zu
LinuXploit