Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/tracer/resources/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/tracer/resources/__pycache__/tracer.cpython-36.opt-1.pyc

3

"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|sttj���||_||_||_||_||_||_dS)N)	rrZdistribution�_PACKAGE_MANAGER�_rules�
_applications�_memory�_hooks_observer�_erased)�selfZpackage_managerZrulesZapplications�memoryZhooks_observerZerased�r�/usr/lib/python3.6/tracer.py�__init__BszTracer.__init__cCsF|jr|jrt|j�S|jr"|jntj�}|jj|�}|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
Cs�|j|�}|j�}i}g}�x&|j�D�]}�x|jj|j�D�]�}tj|�}||krXq>x�||D]�}|j|krrqby�|j	�|j
k�r|j|j�|j|�}|j
j|j��}	|	j�s|	j|k�r|jr�|jj|	�r�tjd|	_t|	j�||	j<t�||	j_|j||	j�||	jjj|�Wqbtk
�r6YqbXqbWq>Wq&W|j
jd�j�r~|j��r~tdtjdtd�d��|d<t|j��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_affectedcCsBtj�}|dkrdStj�}t|�}|j|j�|jj||�dkS)NF����)rZrunning_kernel_package�kernel_package_namerZ	load_inforZcompare_packages)rZrunningr;Zlatestrrrr/�szTracer._has_updated_kernelcCs||j�}|s|S|jj|j��}|jj|j��}|rJ|j|jjdkrJ|S|sX|jr\|S|j|jjdkrx|j|�S|S)NZRETURNzCALL-PARENT)�parentrr+r!�actionZACTIONSr*)r�processr<Zc_ruleZp_rulerrrr*�s
zTracer._apply_rulescCs|jr|j|j�dS)N)rr!)r�apprrrr.�szTracer._call_hookcCsJ|j�}t�}x6|jD],}|j|j|||��|j|j|||��qW|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}x�|D]�}t�}xB|jj|j�D]0}tj|�}||krDq,|j�|j	kr,|j
|�q,W|r|}	||	_||j�}
|
jj
|j�|
jj
|	g�|j
|
g�qW|S)N)r	�files�setrr$r!rr%r'r(�addr&�__dict__r@r)rr>rrCZ
collectionZ
process_filesr4Zmatching_filesZpackage_fileZaff_pkgr2rrrrA�s$


zTracer._affecting_processescCsX|jj|j��siSt�}x8|j�D],}|j|j|||��|j|j|||��q$W|S)N)rr+r!r	Zchildrenr@rArB)rr>rrCrDZchildrrrrB�szTracer._affecting_children)NNF)N)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrrr r8r/r*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

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists