%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.9/site-packages/tracer/resources/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.9/site-packages/tracer/resources/__pycache__/tracer.cpython-39.pyc

a

"e��@s�ddlmZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZmZdd	lmZdd
lmZmZddlmZGdd
�d
e�ZdS)�)�absolute_importN)�
NoSuchProcess)�Package)�System)�FilenameCleaner)�AffectedProcess)�ApplicationsCollection�AffectedProcessesCollection�PackagesCollection)�UnsupportedDistribution)�Applications�AffectedApplication)�_c@s�eZdZdZdZdZdZdZdZdZ	dZ
dZdZddd�Z
dd�Zddd	�Zd
d�Zdd
�Zdd�Zefdd�Zefdd�Zdd�ZdS)�Tracerz9Tracer finds outdated running applications in your systemNFcCs8|stt����||_||_||_||_||_||_dS�N)	rrZdistribution�_PACKAGE_MANAGER�_rules�
_applications�_memory�_hooks_observer�_erased)�selfZpackage_managerZrulesZapplications�memoryZhooks_observerZerased�r�;/usr/lib/python3.9/site-packages/tracer/resources/tracer.py�__init__BszTracer.__init__cCsF|jr|jrt|j�S|jr"|jnt��}|j�|�}|�|j�}|S)z6Returns list of packages what tracer should care about)	�specified_packages�nowr
�	timestamprZ	boot_timerZpackages_newer_than�intersection)rr�packagesrrr�_modified_packagesMs
zTracer._modified_packagesc
Csp|�|�}|��}i}g}|��D�]}|j�|j�D]�}t�|�}||vrNq6||D]�}|j|vrfqVz�|�	�|j
k�r|�|j�|�|�}|j
�|���}	|	j�s|	j|vr�|jr�|j�|	�s�tjd|	_t|	j�||	j<t�||	j_|�||	j�||	jj�|�WqVt�y$YqV0qVq6q"|j
�d�j�sd|���rdtdtjdtd�d��|d<t|���S)z�
		Returns collection of applications which uses some files that have been modified
		@TODO This function should be hardly optimized
		ZERASEDZkernelZSTATICz%You will have to reboot your computer)�name�type�helper)rr!Z
unique_newestr�
package_filesr"r�strip�pid�create_time�modified�append�_apply_rulesr�find�ignorerZprovided_byrZTYPESr#r
�_attributesr	Zaffected_instances�
_call_hookr�_has_updated_kernelrr�values)
r�userrr �affected�found�package�file�p�arrr�trace_affectedWs@




�zTracer.trace_affectedcCsBt��}|durdSt��}t|�}|�|j�|j�||�dkS)NF���)rZrunning_kernel_package�kernel_package_namerZ	load_inforZcompare_packages)rZrunningr;Zlatestrrrr0�szTracer._has_updated_kernelcCsx|��}|s|S|j�|���}|j�|���}|rJ|j|jjdkrJ|S|rT|jsX|S|j|jjdkrt|�|�S|S)NZRETURNzCALL-PARENT)�parentrr,r"�actionZACTIONSr+)r�processr<Zc_ruleZp_rulerrrr+�s

zTracer._apply_rulescCs|jr|�|j�dSr)rr")r�apprrrr/�szTracer._call_hookcCsF|��}t�}|jD],}|�|�|||��|�|�|||��q|S)z�
		Returns collection of processes where each of them contains
		packages which affected it. Packages contains only files matching
		with the particular process
		)r!r	Z	instances�update�_affecting_processes�_affecting_children)rr?�affected_process_factoryr �	processesr>rrr�trace_application�s
zTracer.trace_applicationcCs�t�}|j}|D]�}t�}|j�|j�D]0}t�|�}||vr@q(|��|j	kr(|�
|�q(|r|}	||	_||j�}
|
j�
|j�|
j�
|	g�|�
|
g�q|Sr)r	�files�setrr%r"rr&r(r)�addr'�__dict__r@r )rr>r rCZ
collectionZ
process_filesr5Zmatching_filesZpackage_fileZaff_pkgr3rrrrA�s$

zTracer._affecting_processescCsT|j�|���siSt�}|��D],}|�|�|||��|�|�|||��q"|Sr)rr,r"r	Zchildrenr@rArB)rr>r rCrD�childrrrrB�szTracer._affecting_children)NNF)N)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrrr!r9r0r+r/rrErArBrrrrr!s&


.

r)Z
__future__r�osZpsutilrZtracer.resources.packagerZtracer.resources.systemrZ tracer.resources.FilenameCleanerrZtracer.resources.processesrZtracer.resources.collectionsrr	r
Ztracer.resources.exceptionsrZtracer.resources.applicationsrr
Ztracer.resources.langr�objectrrrrr�<module>s

Zerion Mini Shell 1.0