+
     [;i#  c                   s    ^ RI Ht ^ RIHt ^ RIHt ^ RIHtHt ^ RI	H
t
H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 R]4      t ! R R4      t ! R R]4      tR# )    )absolute_import)minidom)
ExpatError)DATA_DIRUSER_CONFIG_DIRS)PathNotFoundTracerError)ApplicationsCollection)_)	Processes)System)SystemdDbus)	lru_cacheNc                   s   a  ] tR t^#t o ]! R ].],           4      tRRRRRRRR	R
RRR/t]R,          t	Rt
]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]/ 3R l4       t]R 4       tRtV tR# )Applicationsc                s    V R ,           # )z/applications.xml )Zx   &B/usr/lib/python3.14/site-packages/tracer/resources/applications.py<lambda>ZApplications.<lambda>%   s
    Q!44    DAEMONZdaemonSTATICZstaticSESSIONZsessionZAPPLICATIONapplicationZERASEDZerasedUNDEFZ	undefinedNc                sR   \         P                  '       g   \         P                  4        \         P                   F@  pVP                  V 8X  g   K  R V9  d   Vu # \         P	                  VP
                  4      u # 	  \        RV R\         P                  R,          RRRRRR/4      # )	renamenametyper   helperNnoteignoreF)r   _apps_load_definitionsr   findr   ApplicationTYPES)Zapp_nameapp   & r   r!   ZApplications.find2   s    				!!#c	hh(#%3H<+<+<SZZ+HH  
 
	8	<g&T	4U 
 r   c                 sv    \         P                  '       g   \         P                  4        \         P                  # N)r   r   r    r   r   r   allZApplications.allD   s&    				!!#			r   c                 s
   \        4       \        n        \        P                   F  p \        P	                  V 4       K  	  R #   \
         d6   p\        P                  P                  T 4      \        9   g   Th R p?KY  R p?ii ; ir&   )
r   r   r   DEFINITIONS_loadr   osZpathZdirnamer   )fileexs     r   r    ZApplications._load_definitionsK   s[    -/,&&d4  '
 77??4 $44X 5s   AB*A==Bc                sl    \        VR 4      ;_uu_ 4       p\        P                  ! VP                  4       4      pRRR4       XP                  R4       EF  pT P                  T4       TP                   F  pTP                  R8X  d9   \        TP                  P                  4       4      p\         P#                  T4       TP                  R8X  g   K_  T P                  T4       TP                   F^  p	\        T	P                  P                  4       4      p
\        TP                  P                  4       4      p\         P#                  Y4       K`  	  K  	  EK  	  R#   + '       g   i     EL,; i  \         d    \        R4      h\         d"   pRP                  Y4      p\        T4      hRp?ii ; i)ZrNr   zUnable to parse {0}
Hint: {1}applicationsr$   Zgroup)Zopenr   ZparseStringZreadZIOErrorr   r   formatr   ZgetElementsByTagName_remove_unwanted_children
childNodesZnodeNameZdictZ
attributesZitemsr   _append_application)clsr+   ZfZxmldocr,   Zmsgr-   childZattrsr$   Z	app_attrsZgroup_attrss   &&          r   r)   ZApplications._loadT   sG   T31  *F 	 11.Al  .''u~~%""((*+U%%e,~~ ""5)  s~~++-.i))//12k&&y> ! ( B 		 "	j	!!	 	)	0	0	:3	S	s9   E2 %EE2 E/	)E2 /E2 2F3F3F..F3c                s    VP                    F1  pVP                  VP                  8w  g   K   VP                  V4       K3  	  R # r&   )r0   ZnodeTypeZELEMENT_NODEZremoveChild)r2   Znoder3   s   && r   r/   Z&Applications._remove_unwanted_childrenm   s0    enn)))U r   c                s   \        V 4      pVP                  V4       V\        P                  9   dH   \        P                  P	                  V4      p\        P                  V,          P                  V4       R# VP                  R \        P                  4       VP                  R\        P                  V4      4       VP                  RR4       VP                  RR4       \        P                  P                  V4       R# )r   r   r   Nr   F)	r"   updater   r   Zindex
setdefaultDEFAULT_TYPE_helperappend)Zdefault_attrsZspecific_attrsr   Zis   &&  r   r1   Z Applications._append_applications   s    M*+^$L&&&,1a,&,";";<(L$8$8$EF&$'(E*[)r   c                s   V P                   \        P                  R ,          8X  dQ   \        P                  ! 4       R8X  d   RP                  V P                  4      # RP                  V P                  4      # V P                   \        P                  R,          8X  d   \        R4      # V P                   \        P                  R,          8X  d   \        R4      # R# )	r   systemdzsystemctl restart {0}zservice {0} restartr   z%You will have to reboot your computerr   z'You will have to log out & log in againN)r   r   r#   r   init_systemr.   r   r	   )r$   r   r   r7   ZApplications._helper   s    XX##H--i'"))#((33 ''11
xx<%%h//
3
44
xx<%%i00
5
66	r   r   )__name__
__module____qualname____firstlineno__Zmapr   r   r(   r#   r6   r   Zstaticmethodr!   r'   r    Zclassmethodr)   r/   r1   r7   __static_attributes____classdictcell__Z__classdict__   @r   r   r   #   s     4xjCS6ST H
HIM
H	K
 m$	 "     ? ?0  
 79 * *  r   r   c                   s2  a  ] tR t^t o Rt]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 4       t]]! RR7      R 4       4       t]R 4       t]]! RR7      R 4       4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       tRtRtV t R# )r"   a  
Represent the application defined in ``applications.xml``

:param str name: The name of the application
:param str type: See ``Applications.TYPES`` for possible values
:param str helper: Describes how to restart the applications
:param bool note: Provides additional informations to the ``helper``
:param bool ignore: If ``True``, the application won't be printed
:param Processes processes_factory: Class providing list of running processes

Nc                s     Wn         R V n        R # r&   _attributes_cached_name)selfZattributes_dict   &&r   __init__ZApplication.__init__   s    $$r   c                sd    \        V\        4      ;'       d    V P                  VP                  8H  # r&   )
isinstancer"   r   rF   ZotherrG   r   __eq__ZApplication.__eq__   s$    	E;	'	C	CDII,CCr   c                s.    V P                  V4      '       * # r&   )rK   rJ   rG   r   __ne__ZApplication.__ne__   s    [[	r   c                ,    \        V P                  4      # r&   )Zhashr   rF   r   r   __hash__ZApplication.__hash__   s    	diir   c                s(    V P                   V,          # r&   rD   rF   ZitemrG   r   __getattr__ZApplication.__getattr__   s    			$	r   c                rM   r&   )ZlenrD   rN   r   r   __len__ZApplication.__len__   s    	T	r   c                s    WP                   9   # r&   rP   rQ   rG   r   __contains__ZApplication.__contains__   s    	!!	!!r   c                s    R V P                   P                  ,           R,           V P                  R,          ,           R,           # )Z<z: r   Z>)Z	__class__r;   rD   rN   r   r   __str__ZApplication.__str__   s1    	t~~&&	&	-0@0@0H	H3	NNr   c                s"    V P                  4       # r&   )rU   rN   r   r   __repr__ZApplication.__repr__   s    	r   c                s<    V P                   P                  W4       R # r&   )rD   r5   )rF   ZkeyZvalues   &&&r   r5   ZApplication.setdefault   s    c)r   c                s    \        V\        4      '       d   VP                  pV P                  P                  V4       R # r&   )rI   r"   rD   r4   )rF   ZvaluesrG   r   r4   ZApplication.update   s.    $$6&!r   c                sd    V P                   ;'       d    V P                   ^ ,          P                  # )r    )	instancesis_interpretedrN   r   r   rX   ZApplication.is_interpreted   s%     
	<	<DNN1-<<<r   )Zmaxsizec                s    V P                   P                  R 4      '       d$   V P                   P                  R4      '       d   R# V P                  ;'       d    V P                  ^ ,          P                  # )zssh-z-sessionT)r   
startswithZendswithrW   
is_sessionrN   r   r   rZ   ZApplication.is_session   sQ     
YY&!!dii&8&8&D&D
		8	8DNN1-888r   c                sF   V P                   R ,          \        P                  R,          8w  d   V P                   R ,          # V P                  '       d   \        P                  R,          # V P                  '       d   \        P                  R,          # \        P
                  # )r   r   r   r   )rD   r   r#   rZ   
is_servicer6   rN   r   r   r   ZApplication.type   sq    	f!3!3G!<<


6
""	___


Y
''	___


X
&&		"	""r   c                s    \         P                  ! 4       R 8X  d3   \        4       P                  RP	                  V P
                  4      4      # R# )r9   z{0}.serviceN)r   r:   r   Zunit_path_from_idr.   r   rN   r   r   r[   ZApplication.is_service   s<     Y&
-
)
)-*>*>tyy*I
JJ 'r   c                s6   V P                   R ,          ;'       g    \        P                  V 4      p\        P                  ! 4       R8w  dO   V P
                  \        P                  R,          8X  d)   V'       d!   VP                  R4      '       g
   RV,           pV# )r   Zrootr   zsudo )rD   r   r7   r   Zuserr   r#   rY   )rF   r   r%   r   r   ZApplication.helper   sk    H%CC)=)=d)C&[[]fl.@.@.J!JV&&w//vF	-r   c                ~    V P                   '       g   R # \        \        P                  ! RV P                   4      4      # )Nz\{.*\}r   ZboolresearchrN   r   r   helper_contains_formatingZ%Application.helper_contains_formating   s(    	
	bii	4;;/	00r   c                r\   )Nz\{NAME\}r]   rN   r   r   helper_contains_nameZ Application.helper_contains_name   s(    	
	biiT[[1	22r   c           
     s^   . pV P                   '       d   V P                  '       g   VP                  V P                   4       V# V P                   FY  pVP                  V P                   P	                  V P
                  VP
                  VP                  VP                  R7      4       K[  	  V# )aV  
Return the list of helpers which describes how to restart the application.
When no ``helper_format`` was described, empty list will be returned.
If ``helper_format`` contains process specific arguments such a ``{PID}``, etc.
list will contain helper for every application instance.
In other cases, there will be just one helper in the list.
)ZNAMEZPNAMEZPIDZEXE)r   r`   r8   affected_instancesr.   r   pidZexe)rF   helpersprocesss   &  r   rd   ZApplication.helpers   s     '	[[[

(
(
(NN4;; 
. **^^DKK&&99LL
++
++	 '   + 
.r   c                s^   a  S P                   P                  4       P                  V 3R l4      # )zi
Return collection of processes with same name as application.
I.e. running instances of the application
c                 sd   < SP                   R ,          V P                  4       V P                  39   # )r   )rD   r   	real_name)re   rF   s   &r   r   Z'Application.instances.<locals>.<lambda>  s&    4##F+@Q@Q/RRr   )processes_factoryr'   ZfilteredrN   s   fr   rW   ZApplication.instances  s,     
			#	#	%	.	.R
T Tr   rC   )!r;   r<   r=   r>   Z__doc__r
   rg   rD   rH   rK   rL   rO   rR   rS   rT   rU   rV   r5   r4   propertyrX   r   rZ   r   r[   r   r`   ra   rd   rW   rb   r?   r@   rA   rB   r   r"   r"      s*    
 D  "O*"
 = = D9  9
 
# 
# DK  K
   1 1
 3 3
  , T T r   r"   c                   s6   a  ] tR tRt o ]R 4       tR tRtV tR# )AffectedApplicationi  c                sh    V P                   '       g   V P                  4       V n         V P                   # r&   )rE   _namerN   r   r   r   ZAffectedApplication.name   s*     
			zz|4			r   c                s`   \         P                  ! 4       R 8X  d   \        4       p V P                  ^ ,          P                  pV'       d   V P                  '       d   VP                  V4      '       dh   VP                  VR4      '       gP   VP                  VR4      pV'       d6   \        P                  ! RV4      '       d   \        P                  ! RRV4      # V P                  '       d   V P                  ^ ,          P                  # V P                  R,          #   \
         d    Rp Li ; i)r9   NZPAMNameIdz
\.service$Z r   )r   r:   r   rW   rc   Z
IndexErrorZunit_path_from_pidZhas_service_property_from_pidZget_unit_property_from_pidr^   r_   ZsubrX   rf   rD   )rF   Zbusrc   rk   s   &   r   rj   ZAffectedApplication._name(  s    Y&	3
..


C 
~~~#0055--c9==))#t4b			-,,ff]B++	
..

%
%%			&	!!  
Cs   D D-,D-)rE   N)	r;   r<   r=   r>   rh   r   rj   r?   r@   rA   rB   r   ri   ri     s!     
 " "r   ri   )Z
__future__r   Zxml.domr   Zxml.parsers.expatr   Ztracer.pathsr   r   Ztracer.resources.exceptionsr   r   Ztracer.resources.collectionsr   Ztracer.resources.langr	   Ztracer.resources.processesr
   Ztracer.resources.systemr   Ztracer.resources.SystemdDbusr   Ztracer.resources.pycompr   r*   r^   Zobjectr   r"   ri   r   r   r   <module>rl      sV   & '  ( 3 A ? # 0 * 4 - 	 	m6 m`I IX"+ "r   