+
     Gi?  c                   s    ^ RI Ht ^ RIt^ RIHt ^ RIHt ^RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt ! R R	]4      tR# )
    )print_functionN)commands)Locator)TunedAdminDBusException)TunedException)ProfileRecommenderc                   s  a  ] tR t^t o RRR]P
                  ]P                  3R ltR t	R t
R tR tR tR	 tR
 tR tR tR tR tR tR tR tR6R ltR6R ltR tR tR tR tR tR tR tR t R t!R t"R t#R t$R  t%R! t&R" t'R# t(R$ t)R% t*R& t+R' t,R( t-R) t.R7R* lt/R7R+ lt0R8R, lt1R8R- lt2R. t3R/ t4R0 t5R1 t6R2 t7R3 t8R4t9V t:R5# )9AdminTFc                sz   W n         W0n        W@n        WPn        \	        V4      V n        \        V4      V n        \        P                  ! 4       V n
        R V n        RV n        R V n        RV n        RV n        W`n        \#        4       V n        V P                   '       d   V P'                  4       V n        R# RV n        R# ) TNF)_dbus_debug_async_timeoutr   _cmdprofiles_locator_profiles_locator	threadingZ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_dirsZdbusZdebugZasyncotimeoutZ	log_levels   &&&&&&&6/usr/lib/python3.14/site-packages/tuned/admin/admin.py__init__ZAdmin.__init__   s     *++-uo$)+L9$!*!2$ "$#$!$$$//02$,0JJJt($E$    c                sz   \         P                  P                  \        P                  \        P
                  \        P                  V P                  4      V n         V P                  P                  \        P                  V P                  4       R #   \         d   pT P                  T4        Rp?R# Rp?ii ; iTNF)tunedZadminZDBusControllerconstsZDBUS_BUSZDBUS_INTERFACEZDBUS_OBJECTr
   r   Zset_signal_handlerZSIGNAL_PROFILE_CHANGED_signal_profile_changed_cbr   _errorr   e   & r   r   ZAdmin._init_dbus%   s    [[//AVAVX^XjXjlplwlwx$&&v'D'DdFeFef
	  ;;q>
s   4B B:B55B:c                s<    \        V\        P                  R 7       R# ))fileN)printsysstderr)r   Zmessage   &&r   r$   ZAdmin._error.   s    cjj!r   c                s    V P                   P                  4       '       g/   Wn        W n        W0n        V P                   P                  4        R # R # N)r   Zis_setr   r   r   Zset)r   profile_nameZresultZerrstrs   &&&&r   r#   Z Admin._signal_profile_changed_cb1   s@    		%	%	,	,	.	.!- & &##%	 
/r   c                s4    \         P                  ! \        V P                  P	                  \
        P                  4      4      ^ 4       R#   \         d(   pTP                  \        P                  8H  u Rp?# Rp?i\        \        3 d   p Rp?R# Rp?ii ; i)r    NFT)osZkillZintr   Z	read_filer"   ZPID_FILEZOSErrorerrnoZEPERMZ
ValueErrorZIOErrorr%   r'   r   _tuned_is_runningZAdmin._tuned_is_running9   sh    773tyy""6??34a8
 
	 
 !
''U[[
  
g	 
s*   AA BA82B8BBBc                s   Ve   VR8X  d   R# R pR pRp \        V RV,           4      p \        V RV,           4      pV P                  '       da    V P
                  P                  V P                  4       V P
                  P                  ! V.VO5/ VB  V P
                  P                  4       pV P                  '       g	   V! V/ VB pV#   \         d   pRT n         R p?LR p?ii ; i  \         dK   pT P                  '       g/   T P                  \	        T4      RT,          ,           4        R p?R#  R p?LR p?ii ; i  \         d#   pT P                  T4       RT n         R p?LR p?ii ; i)Nr   FZ_action_dbus_Z_action_z , action '%s' is not implemented)ZgetattrZAttributeErrorr   r$   strr   Zset_on_exit_action_log_capture_finish
set_actionZrunr   )r   Zaction_nameZargsZkwargsactionZaction_dbusresr&   s   &&*,    r   r5   ZAdmin.actionC   sU   K2-
&+#<=;D*{236
 
''
 =d=f=





 C
 
					 	 3	*) 
 4 
 



KKA;kIIJ  " KKNDsG   C
 C) AE 
C&C!!C&)D>4:D99D>E.E))E.c           
     s   \        R 4       V Fy  pV^,          eS   V^,          R8w  dE   \        V P                  P                  RV^ ,          ,          ^RV^,          ,          4      4       K`  \        RV^ ,          ,          4       K{  	  R# )zAvailable profiles:Nr   z- %s)r)   r   Z	align_str)r   profile_namesprofile   && r   _print_profilesZAdmin._print_profilesa   sh    gajr!1	$))

fwqz12v
7J
KL	&71:
	 r   c                s@    V P                   P                  4       pV P	                  V4       V P                  4        V P                   P                  R4      #   \         d;   pT P                   P                  4        Uu. uF  q3R 3NK  	  Mu upi pp Rp?L|Rp?ii ; ir   NT)r   Z	profiles2r   profilesr:   _action_dbus_activeexit)r   r7   r&   r8      &   r   _action_dbus_list_profilesZ Admin._action_dbus_list_profilesi   s    N##--/= }%					t	$$ 
! N151A1A1J1J1LM1LgbM1LM=M=Ns#   A B#B?BBBc                sx    V P                  V P                  P                  4       4       V P                  4        R # T)r:   r   Zget_known_names_summary_action_activer      &r   _action_list_profilesZAdmin._action_list_profiless   s.    t--EEGH	r   c                s    V P                   P                  4       pVR 8X  d   RpV P                   P                  R4       V# r;   )r   active_profiler>   r   r.   r'   r   _dbus_get_active_profileZAdmin._dbus_get_active_profilex   s=    !!002,R<	r   c                s>    V P                   P                  4       w  rV# r-   )r   get_active_profile)r   r.   manual   &  r   _get_active_profileZAdmin._get_active_profile   s    557,	r   c                s    V P                   P                  4       w  rVf   VR JpV'       d   \        P                  # \        P                  # r-   )r   rI   r"   ZACTIVE_PROFILE_MANUALZACTIVE_PROFILE_AUTO)r   r8   rJ   rK   r   _get_profile_modeZAdmin._get_profile_mode   s?    ii2247^46)/	%	%OV5O5OOr   c                sL    V P                   P                  4       pVR 8X  d   RpV# )r   N)r   post_loaded_profilerG   r'   r   _dbus_get_post_loaded_profileZ#Admin._dbus_get_post_loaded_profile   s)    !!557,R<	r   c                s:    V P                   P                  4       pV# r-   )r   Zget_post_loaded_profilerG   r'   r   _get_post_loaded_profileZAdmin._get_post_loaded_profile   s    224,	r   c                s    V^ ,          R8X  dn   \        R4       \        V^,          4       \        4        \        R4       \        V^,          4       \        4        \        R4       \        V^,          4       R# \        RV,          4       R# )r    TzProfile name:zProfile summary:zProfile description:z,Unable to get information about profile '%s'Fr)   )r   r8   profile_info   &&&r   _print_profile_infoZAdmin._print_profile_info   sj    !_a7	a7	 a
	7'	AB
r   c                s    VR 8X  d   V P                  4       pV'       d,   V P                  WP                  P                  V4      4      pM\	        R4       RpV P                  P                  V4      # )r   No current active profile.F)rH   rT   r   rR   r)   r>   )r   r8   r6   r9   r   _action_dbus_profile_infoZAdmin._action_dbus_profile_info   s`    ]**,7		!	!'+;+;+H+H+Q	R3	%&	3					s	##r   c           	     sT   VR 8X  d$    V P                  4       pVf   \        R4       R#  V P                  WP                  P                  V\        P                  \        P                  .R R .4      4      #   \         d&   pT P                  \	        T4      4        Rp?R# Rp?ii ; i)r   NrU   F)rL   r)   r   r$   r2   rT   r   Zget_profile_attrsr"   ZPROFILE_ATTR_SUMMARYZPROFILE_ATTR_DESCRIPTION)r   r8   r&   r9   r   _action_profile_infoZAdmin._action_profile_info   s    ]&&(G
'(  
	!	!'+A+A+S+ST[^d^y^y  |B  |[  |[  ^\  _a  ce  ^f  ,g  
h  h  KKAs   A7 7B'B""B'c                sL    Vf   \        R4       R# \        RV,          4       R# )NrU   FzCurrent active profile: %sTrQ   rG   r,   r   _print_profile_nameZAdmin._print_profile_name   s%    	%&
	%	45	r   c                s>    V'       d   \        R V,          4       R# R# )zCurrent post-loaded profile: %sNrQ   rG   r,   r   _print_post_loaded_profileZ Admin._print_post_loaded_profile   s    	*\	9: r   c                s    V P                  4       pV P                  V4      pV'       d"   V P                  4       pV P                  V4       V P                  P                  V4      # r-   )rH   rX   rO   rY   r   r>   )r   rF   r6   rN   r?   r   r=   ZAdmin._action_dbus_active   sX    002.  0#;;=""#67					s	##r   c                s    V P                  4       pV P                  4       pV'       d   V'       d   VR ,          pMRpW,          pTeP   T P                  4       '       g:   \        R4       \        RT,          4       T'       d   \        RT,          4       R# T P                  T4      pT P                  T4       T#   \         d&   pT P                  \	        T4      4        Rp?R# Rp?ii ; i) r   NFzKIt seems that tuned daemon is not running, preset profile is not activated.zPreset profile: %szPreset post-loaded profile: %sT)	rL   rP   r   r$   r2   r1   r)   rX   rY   )r   r.   rN   r&   r6      &    r   rB   ZAdmin._action_active   s    **,<668 S\\'L d&<&<&>&>	VW		,-	
*-@
@A
  .#!!"56	* 
 ;;s1v
s!   'B= B= B= =C-C((C-c                s*    \        R V,           4       R# )zProfile selection mode: NrQ   )r   moder,   r   _print_profile_modeZAdmin._print_profile_mode   s    "T)*r   c                s    V P                   P                  4       w  rV P                  V4       VR 8w  d-   V P                  V4       V P                   P	                  R4      # V P                   P	                  R4      # )r   FT)r   Zprofile_moder]   r$   r>   )r   r\   ZerrorrK   r   _action_dbus_profile_modeZAdmin._action_dbus_profile_mode   sg      --/+$4 
b[;;u





&&					t	$$r   c                s     V P                  4       pV P                  V4       R #   \         d&   pT P                  \	        T4      4        Rp?R# Rp?ii ; ir    )rM   r]   r   r$   r2   )r   r\   r&   rK   r   _action_profile_modeZAdmin._action_profile_mode   sI    

 
 
"4D!
	 ;;s1v
s   !% AAAc                s    V'       dV   V P                   P                  4       '       g4   V P                   P                  4       '       g   V P                  R 4       RpV# V P                  RV,          4       V# )zCannot enable the tuning.FzUnable to switch profile: %s)r   Z
is_runningZstartr$   r   retmsgrS   r   _profile_print_statusZAdmin._profile_print_status   s`    



%
%
'
'0@0@0F0F0H0HKK+,
C 
* ;;-34	*r   c                s   \         P                   ! 4       V P                  V P                  ,           8  d8   \        R V P                  ,          4       V P                  P                  R4      # V P                  P                  4       '       dv   V P                  V8X  de   V P                  '       g8   \        RV P                  ,          4       V P                  P                  R4      # V P                  P                  R4      # R# )zOperation timed out after waiting %d seconds(s), you may try to increase timeout by using --timeout command line option or using --async.FzError changing profile: %sT)time
_timestampr   r)   r   r>   r   ZisSetr   r   r   rG   r,   r   _action_dbus_wait_profileZAdmin._action_dbus_wait_profile  s    	YY[DOOdmm33  
U  X\  Xe  Xe  
e  f





&&	!!''))
!!\1%%%
'$*D*DDE!!%((  &&	r   c                sj   V P                   e   V P                   R8X  d   R #  V P                  P                  V P                   4      pR V n         \        VR\        P
                  R7       \        P
                  P                  4        R #   \         d   pT P                  R4        R p?R # R p?ii ; i)Nr   )Zendr(   zUError: Failed to stop log capture. Restart the TuneD daemon to prevent a memory leak.)	r   r   Zlog_capture_finishr)   r*   r+   Zflushr   r$   )r   Zlog_msgsr&   rK   r   r3   ZAdmin._log_capture_finish  s    	__2 5	h11	__84?CJJ/::	  h;;fgghs   A&B B2B--B2c                s
   \        V4      ^ 8X  d   V P                  4       # RP                  V4      pVR8X  d   V P                  P	                  R4      # V P
                  P                  4        V P                  '       gT   V P                  eF   V P                  ^,           ^,           pV P                  P                  V P                  V4      V n        V P                  P                  V4      w  rEV P                  '       g	   V'       g+   V P                  P	                  V P                  WE4      4      # \        P                  ! 4       V n        V P                  P!                  V P"                  V4       V P                  WE4      # )r    rZ   r   F)len_action_dbus_listjoinr   r>   r   clearr   r   r   log_capture_startr   Zswitch_profilerc   rd   re   r4   rf   )r   r<   r.   r   ra   rb      &&    r   _action_dbus_profileZAdmin._action_dbus_profile  s!   ]a

 
 
""(#,R





&&$$&	4]]R!#7%%77	__g4?..|<*3	[[[




 : :3 D
EEYY[4?t==|L		#	#C	--r   c                s    \        R 4       V P                  P                  . RO4      w  rV^ 8w  d   \        R4      h\        R4       R# )zTrying to (re)start tuned...z5TuneD (re)start failed, check TuneD logs for details.zTuneD (re)started.N)Zservicer!   Zrestart)r)   r   Zexecuter   r`   rK   r   _restart_tunedZAdmin._restart_tuned.  s>    &'yy  !@A*3AX	O	PPr   c                s    WP                   P                  4       9   d    V P                  '       d9   V P                  4        V P	                  4       '       d   V P                  V.4      # V P                  P                  W4       V P                  4        \        R 4       R# V P                  RV,          4       R#   \         d7   pT P                  \        T4      4       T P                  R4        Rp?R# Rp?ii ; i)z[TuneD is not active on the DBus, not checking whether the profile was successfully applied.TzUnable to switch profile.NFz%Requested profile '%s' doesn't exist.)r   Zget_known_namesr	   rn   r   rm   r   Zsave_active_profiler)   r   r$   r2   )r   r.   rJ   r&   s   &&& r   _set_profileZAdmin._set_profile5  s    ++;;==zzz	&&~66II!!,7	
gh ;;6EF
  KKAKK+,s(   B< %B< B< *6B< <C=+C88C=c                s    \        V4      ^ 8X  d   V P                  4       # RP                  V4      pVR8X  d   R# V P                  VR4      # )r    rZ   r   FT)rg   rE   ri   ro   )r   r<   r.   r9   r   _action_profileZAdmin._action_profileH  sI    ]a

$
$
&&(#,R
			<	..r   c                s   V P                   P                  4       pV P                  P                  4        V P                  '       gT   V P
                  eF   V P                  ^,           ^,           pV P                   P                  V P
                  V4      V n        V P                   P                  4       w  r4V P                  '       g	   V'       g+   V P                   P                  V P                  W44      4      # \        P                  ! 4       V n        V P                   P                  V P                  V4       V P                  W44      # r-   )r   recommend_profiler   rj   r   r   r   rk   r   Zauto_profiler>   rc   rd   re   r4   rf   )r   r.   r   ra   rb   r[   r   _action_dbus_auto_profileZAdmin._action_dbus_auto_profileP  s    !!335,$$&	4]]R!#7%%77	__g4?,,.*3	[[[




 : :3 D
EEYY[4?t==|L		#	#C	--r   c                sZ    V P                   P                  4       pV P                  VR 4      # F)r   	recommendro   rG   r'   r   _action_auto_profileZAdmin._action_auto_profile`  s)    **446,			<	//r   c                s~    \        V P                  P                  4       4       V P                  P                  R 4      # rA   )r)   r   rq   r>   rC   rD   r   _action_dbus_recommend_profileZ$Admin._action_dbus_recommend_profiled  s0    **,-					t	$$r   c                sL    \        V P                  P                  4       4       R # rA   )r)   r   rt   rC   rD   r   _action_recommend_profileZAdmin._action_recommend_profileh  s    !!++-.	r   c                s   V'       d   V P                   P                  4       pMV P                   P                  4       pV'       d   \        R 4       MB\        R4       \        R4       \        R4       \        R4       \        R4       \        R4       \        R\        P
                  ,          4       V P                   P                  V4      # )zIVerification 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 tunedZ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   Zverify_profile_ignore_missingZverify_profiler)   r"   ZLOG_FILEr>   )r   ignore_missingra   r9   r   _action_dbus_verify_profileZ!Admin._action_dbus_verify_profilel  s    				7	7	93				(	(	*3	TU	WX	HI	$%;	"#	YZ06??BC					s	##r   c                    \        R 4       R# z Not supported in no_daemon mode.FrQ   )r   rx   r,   r   _action_verify_profileZAdmin._action_verify_profile}      *+	r   c                s    ^pV P                   P                  V P                  V4      V n        V P                   P	                  4       pV'       g   V P                  R4       V P                   P                  V4      # )i   zCannot disable active profile.)r   rk   r   r   Zoffr$   r>   )r   r   ra   rK   r   _action_dbus_offZAdmin._action_dbus_off  sc    '$$66OOW$/#	;;/0					s	##r   c                rz   r{   rQ   rC   rD   r   _action_offZAdmin._action_off  r}   r   c                f    VR8X  d   V P                  4       # VR8X  d   V P                  VR7      # R# )aF  Print 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
r<   pluginsverboseN)r@   _action_dbus_list_pluginsr   Zlist_choicer   rS   r   rh   ZAdmin._action_dbus_list  s<     J

)
)
++i

(
(
(
99  r   c                r   )ac  Print 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
r<   r   r   N)rE   _action_list_pluginsr   rS   r   _action_listZAdmin._action_list  s<     J

$
$
&&i

#
#G
#
44  r   c                s   V P                   P                  4       pVP                  4        F  p\        V4       V'       d   \	        W#,          4      ^ 8X  d   K.  V P                   P                  V4      pW#,           FC  p\        RV,          4       VP                  VR4      pV'       g   K1  \        RV,          4       KE  	  K  	  V P                   P                  R4      # )zpPrint accessible plugins

Keyword arguments:
verbose -- if is set to True then parameters and hints are printed
z	%sNz		%sT)r   Zget_pluginsZkeysr)   rg   Zget_plugin_hintsZgetr>   )r   r   r   pluginZhintsZ	parameterZhint   &&     r   r   ZAdmin._action_dbus_list_plugins  s     ((*'f=
S)Q.,,V45OOy	&9
99Y%Dt
8d	 $  
				t	$$r   c                rz   r{   rQ   )r   r   r,   r   r   ZAdmin._action_list_plugins  r}   r   c                s    V P                   P                  W4      w  r4V'       g   V P                  R V,          4       V P                   P                  V4      # )zUnable to acquire devices: %s)r   Zinstance_acquire_devicesr$   r>   )r   devicesinstancera   rb   s   &&&  r   %_action_dbus_instance_acquire_devicesZ+Admin._action_dbus_instance_acquire_devices  sF    88K*3	;;.45					s	##r   c                rz   r{   rQ   )r   r   r   rS   r    _action_instance_acquire_devicesZ&Admin._action_instance_acquire_devices  r}   r   c                s&   V P                   P                  V4      w  r#pV'       g4   V P                  R V,          4       V P                   P                  R4      # V F  w  rV\	        V: RV: R24       K  	  V P                   P                  R4      # )zUnable to list instances: %sFz (Z)T)r   Zget_instancesr$   r>   r)   )r   plugin_namera   rb   Zpairsr   r   r   r   _action_dbus_get_instancesZ Admin._action_dbus_get_instances  sz    &&44[A3U	;;-34





&&hh	'(  					t	$$r   c                rz   r{   rQ   )r   r   r,   r   _action_get_instancesZAdmin._action_get_instances  r}   r   c                s   V P                   P                  V4      w  r#pV'       g4   V P                  R V,          4       V P                   P                  R4      # V F  p\	        V4       K  	  V P                   P                  R4      # )zUnable to list devices: %sFT)r   Zinstance_get_devicesr$   r>   r)   )r   r   ra   rb   r   Zdevicerl   r   !_action_dbus_instance_get_devicesZ'Admin._action_dbus_instance_get_devices  sq    ((==hG3W	;;+c12





&&f= 					t	$$r   c                rz   r{   rQ   )r   r   r,   r   _action_instance_get_devicesZ"Admin._action_instance_get_devices  r}   r   )r   r   r   r   r   r   r   r	   r   r
   r   r   r   r   r   re   N)r   )r<   Frs   );Z__name__Z
__module__Z__qualname__Z__firstlineno__r"   ZADMIN_TIMEOUTloggingZERRORr   r   r$   r#   r1   r5   r:   r@   rE   rH   rL   rM   rO   rP   rT   rV   rW   rX   rY   r=   rB   r]   r^   r_   rc   rf   r3   rm   rn   ro   rp   rr   ru   rv   rw   ry   r|   r~   r   rh   r   r   r   r   r   r   r   r   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r      s    )-uV11}}B&"&<%
P$
h;$2+%

h.(&/. 0%$"$:5%&$%% r   r   )Z
__future__r   Ztuned.adminr!   Ztuned.utils.commandsr   Ztuned.profilesr   r   Z
exceptionsr   Ztuned.exceptionsr   Ztuned.constsr"   Ztuned.utils.profile_recommenderr   r/   r*   r0   rd   r   r   Zobjectr   ) r   r   <module>r      s=    %  ) 6 / +  > 	 
    SF Sr   