+
     [;iq#  c                   s    ^RI Ht ^RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHtH	t	 ^ RI
Ht ^ RIHt  ! R R]4      t ! R	 R
]4      t ! R R]4      t ! R R]! ]]4      4      t ! R R]4      tR# )   )ProcessesCollection)FilenameCleanerN)PIPEPopen)Timer)with_metaclassc                   s@   a  ] tR t^t o ]R 4       t]R 4       tRtV tR# )	Processesc                 sz     \         P                  ! 4       #   \         d    \         P                  ! 4       u # i ; iN)psutilpidsAttributeErrorZget_pid_list     ?/usr/lib/python3.14/site-packages/tracer/resources/processes.pyr
   ZProcesses.pids!   s1     
++-	  



 s     ::c                 s    \        4       p \        P                  4        F  p V P                  \	        V4      4       K   	  V #   \
        P                   d     K<  \
        P                   d     KS  i ; ir   )r   r   r
   appendProcessr	   ZNoSuchProcessAccessDenied)Z	processespids     r   allZProcesses.all(   s]    !#)^^c$WS\" 
 
 

$


#t#s   AA3A3.A32A3r   N)	__name__
__module____qualname____firstlineno__staticmethodr
   r   __static_attributes____classdictcell____classdict__   @r   r   r      s-           r   r   c                   s   a  ] tR t^3t o RtRR ltR tR tR tR t	R t
R	 tR
 tR tR tRR ltR tR tRR ltRtV tR# )ProcessWrappera  
Wrapper for ``psutil.Process class``
Library ``psutil`` is not backward compatible from version 2.x.x to 1.x.x.

Purpose of this class is cover incompatibility in ``psutil.Process`` class and
provide interface of new version. It allows using new interface even with
old version of ``psutil``.

Note that, for performance reasons, process information is cached at
object creation. To force a refresh, invoke the ``rebuild_cache()``
method.
Nc                s\    \         P                  ! V4      V n        V P                  4        R # r   )r	   r   _processrebuild_cacheselfr      &&r   __init__ZProcessWrapper.__init__A   s    ..%$-r   c                ,    \        V P                  4      # r   )Zboolr   r"      &r   __nonzero__ZProcessWrapper.__nonzero__E   s    	dmm	r   c                sL    V P                   P                  . ROR7      V n        R# )name)ZattrsN)r)   execmdlineppidusernamecreate_time)r   Zas_dict	_procdictr&   r'   r   r    ZProcessWrapper.rebuild_cacheH   s    ==((/l(m$.r   c                s    V P                  R 4      R8X  d   V P                  R4      V P                  R4      9  d_   \        V P                  R4      4      ^8  d@   V P                  R4      ^,          P                  R4      ^ ,          pRP                  V4      # T P                  R 4      #   \        P
                   d     L(i ; i)r)   Zsshdr*   r+   Z@zssh-{0}-session)_attrZlenZsplitformatr	   r   )r"   r-      & r   r)   ZProcessWrapper.nameK   s    
jjF"zz%

9 55#djj>S:TWX:Xzz)$Q'--c215X$$X.. 
F	 
		 s   BB, ,CCc                $    V P                  R 4      # )r*   r0   r&   r'   r   r*   ZProcessWrapper.exeW   s    	E	r   c                r3   )r+   r4   r&   r'   r   r+   ZProcessWrapper.cmdlineZ   s    	I	r   c                r3   )r,   r4   r&   r'   r   r,   ZProcessWrapper.ppid]   s    	F	r   c                r3   )parentr4   r&   r'   r   r5   ZProcessWrapper.parent`   s    	H	r   c                r3   )r-   r4   r&   r'   r   r-   ZProcessWrapper.usernamec   s    	J	r   c                r3   )r.   r4   r&   r'   r   r.   ZProcessWrapper.create_timef   s    	M	""r   c                s.   R P                  V4      pW P                  9  d*    V P                  P                  V4      V P                  V&   V P                  V,          #   \         d,    T P                  P                  T4      T P                  T&    LHi ; i)zchildren-{0})r1   r/   r   childrenr   Zget_children)r"   	recursivekey   && r   r6   ZProcessWrapper.childreni   s    i(#@--00;DNN3 
	  @--44Y?DNN3@s   (A 3BBc                s    WP                   9  d,   \        V P                  V4      p V! 4       V P                   V&   V P                   V,          #   \         d    Y P                   T&    L.i ; ir   )r/   getattrr   Z	TypeError)r"   r)   Zattrr9   r   r0   ZProcessWrapper._attrr   s_    	
$--
&4 6DNN4 
	   NN4 s   A A+*A+c                s.    \        V P                  V4      # r   )r:   r   )r"   Zitemr#   r   __getattr__ZProcessWrapper.__getattr__{   s    		%%r   c                s2   R P                  V4      pW P                  9  d+    V P                  P                  VR7      V P                  V&   V P                  V,          #   \         d-    T P                  P                  TR7      T P                  T&    LIi ; i)zmemory_maps-{0})grouped)r1   r/   r   memory_mapsr   Zget_memory_maps)r"   r<   r8   r9   r   r=   ZProcessWrapper.memory_maps   s      )#I--33G3DDNN3 
	  I--777HDNN3Is   )A 4BB)r/   r   r   F)T)r   r   r   r   __doc__r$   r(   r    r)   r*   r+   r,   r5   r-   r.   r6   r0   r;   r=   r   r   r   r   r   r   r   3   sV     n
 #& r   r   c                   s<   a a ] tR t^t oRtV 3R ltR tRtVtV ;t	# )ProcessMetaz
Caching metaclass that ensures that only one ``Process`` object is ever
instantiated for any given PID. The cache can be cleared by calling
``Process.reset_cache()``.

Based on https://stackoverflow.com/a/33458129
c                sf   <a  \         \        S `  WV4       V 3R  lpV! 4        \        S RV4       R# )c                  s   < / S n         R # r   )_cache)clss   r   reset_cacheZ)ProcessMeta.__init__.<locals>.reset_cache   s
    3:r   rC   N)superr@   r$   Zsetattr)rB   r)   ZbasesZ
attributesrC   	__class__s   f&&& r   r$   ZProcessMeta.__init__   s*    S"4
;-	#}k*r   c                s    V^ ,          pW0P                   9  d;   V P                  ! V .VO5/ VB pV P                  ! V.VO5/ VB  W@P                   V&   V P                   V,          # )i    )rA   Z__new__r$   )rB   ZargsZkwargsr   r"   s   &*,  r   __call__ZProcessMeta.__call__   s\    Q#


++c
+D
+F
+4<<&t&v&::c?	Cr   r   )
r   r   r   r   r?   r$   rF   r   r   __classcell__rE   r      @@r   r@   r@      s     + r   r@   c                   s   a a ] tR t^t oRtR tR tR t]RR l4       t	]
R 4       tR tV 3R ltRV 3R	 llt]
V 3R
 l4       t]
R 4       t]
R 4       t]
R 4       t]
R 4       tRtVtV ;t# )r   aH  
Represent the process instance uniquely identifiable through PID

For all class properties and methods, please see
http://pythonhosted.org/psutil/#process-class

Below listed are only reimplemented ones.

For performance reasons, instances are cached based on PID, and
multiple instantiations of a ``Process`` object with the same PID will
return the same object. To clear the cache, invoke
``Process.reset_cache()``. Additionally, as with ``ProcessWrapper``,
process information is cached at object creation. To force a refresh,
invoke the ``rebuild_cache()`` method on the object.
c                s4    V P                   VP                   8H  # )zBFor our purposes, two processes are equal when they have same name)r   r"   processr#   r   __eq__ZProcess.__eq__   s    	W[[	  r   c                s.    V P                  V4      '       * # r   )rL   rJ   r#   r   __ne__ZProcess.__ne__   s    [[!	!!r   c                r%   r   )Zhashr   r&   r'   r   __hash__ZProcess.__hash__   s    	dhhr   c                s   \        RRV .\        \        R7      p\        WP                  4      p VP	                  4        VP                  4        VP                  ^ 8H  VP                  4        #   TP                  4        i ; i)z
Process arguments could be referring to files on remote filesystems and
os.path.isfile will hang forever if the shared FS is offline.
Instead, use a subprocess that we can time out if we can't reach some file.
Ztestz-f)ZstdoutZstderr)r   r   r   ZkillZstartZcommunicateZ
returncodeZcancel)Z	file_pathZtimeoutrK   Ztimers   &&  r   safe_isfileZProcess.safe_isfile   sb     64+DF'

&%;;=




!<<>5<<>s   .A/ /Bc                s   . pV P                  4        F2  pVP                  \        P                  ! VP                  4      4       K4  	  V P                  4       R ,           FX  p\        P                  P                  V4      '       g   K*  \        P                  V4      '       g   KG  VP                  V4       KZ  	  \        V4      # :r    NN)r=   r   r   Zstrippathr+   osZisabsr   rO   Zsorted)r"   filesZmmaparg   &   r   rS   ZProcess.files   s    
%  d<<%%dii01 ! \\^Bc
''--

#	LL   
r   c                sd    V P                  4       '       d   \        V P                  4       4      # R# )zGThe parent process casted from ``psutil.Process`` to tracer ``Process``N)r,   r   r&   r'   r   r5   ZProcess.parent   s!    	YY[[
$))+
	r   c                sN   <  \         \        V `  4       #   \         d     R# i ; i)zaThe user who owns the process. If user was deleted in the meantime,
``None`` is returned instead.N)rD   r   r-   ZKeyError)r"   rE   s   &r   r-   ZProcess.username   s*    


'
))	 
s    $$c                s   < \         \        V `  V4      p\        V Uu. uF  p\        VP                  4      NK  	  up4      # u upi )zhThe collection of process's children. Each of them casted from ``psutil.Process``
to tracer ``Process``.)rD   r   r6   r   r   )r"   r7   r6   ZchildrE   s   &&  r   r6   ZProcess.children   s<     7D*95(	hGhUgeii0hG	HHGs   Ac                s   < \         \        V `  4       pVP                  R4      '       d   V^ R pRV9   d   V^ VP	                  R4       pV# )zaThe absolute path to process executable. Cleaned from arbitrary strings
which appears on the end.z#newZ;i)rD   r   r*   ZendswithZindex)r"   r*   rE   s   & r   r*   ZProcess.exe   sP     	gt "#\\&	Qr3 	CZ	Qsyy~	3	*r   c                s(    V P                  4       R9   # )python)rV   )r)   r&   r'   r   is_interpretedZProcess.is_interpreted  s     

	""r   c                s    V P                  4       pVf   R # V P                  4       pVe   WP                  4       8w  d   R# R # )NT)terminalr5   )r"   rX   r5   s   &  r   
is_sessionZProcess.is_session  s:    ]]_(
;;=&^x??#44
 5r   c                s   V P                   '       de   V P                  4       R ,           FI  p\        P                  P	                  V4      '       g   K*  \        P                  P                  V4      u # 	  V P                  4       # rP   )rW   r+   rR   rQ   ZisfileZbasenamer)   )r"   rT   r2   r   	real_nameZProcess.real_name  s\    	llnR  s	ww~~cGGS!! ! 
r   c                s   \         P                   P                  \        P                  ! 4       4      p\         P                   P                  V P                  4       4      pW,
          pRpVP                  ^ 8  d   \        VP                  4      R,           pV# VP                  R8  d/   \        \        VP                  R,          4      4      R,           pV# VP                  ^<8  d/   \        \        VP                  ^<,          4      4      R,           pV# VP                  ^ 8  d&   \        \        VP                  4      4      R,           pV# )z
The time of how long process is running. Returned as string
in format ``XX unit`` where unit is one of
``days`` | ``hours`` | ``minutes`` | ``seconds``
Z z daysz hoursz minutesz secondsi  )datetimeZfromtimestamptimer.   ZdaysZstrZsecondsZint)r"   ZnowZstartedZstarted_strrU   r   str_started_agoZProcess.str_started_ago  s    	''		4#++D,<,<,>?'M'+\\AW\\"W,; 
 '!SG456A; 
 "S2-./*<; 
 !S)*Z7;	r   r   )g      ?r>   )r   r   r   r   r?   rL   rM   rN   r   rO   ZpropertyrS   r5   r-   r6   r*   rW   rY   rZ   r]   r   r   rG   rH   rI   r   r   r      s      !"    "I    # #       r   r   c                   s8   a  ] tR tRt o RtRtRR ltR tRtV t	R# )AffectedProcessi5  Nc                sl    \         P                  W4       \        4       V n        \        4       V n        R # r   )r   r$   ZsetpackagesrS   r!   r#   r   r$   ZAffectedProcess.__init__9  s"    	4%$-u$*r   c                s    V P                   P                  VP                   4      V n         V P                  P                  VP                  4      V n        R # r   )rS   Zunionr_   rJ   r#   r   updateZAffectedProcess.update>  s8    zz.$*--%%g&6&67$-r   )rS   r_   r   )
r   r   r   r   r_   rS   r$   r`   r   r   r   r   r   r^   r^   5  s     	
8 8r   r^   )Zcollectionsr   r   r	   r[   r\   rR   Z
subprocessr   r   Z	threadingr   Zsixr   Zobjectr   r   Ztyper@   r   r^   r   r   r   <module>ra      sk   & - ,    	 "   *SV Sl$ 2Pn[.9 Pf8g 8r   