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__/applications.cpython-36.opt-1.pyc

3

"e�#�@s�ddlmZddlmZddlmZddlmZmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlZddlZGd
d�de�ZGdd�d�ZGdd�de�ZdS)�)�absolute_import)�minidom)�
ExpatError)�DATA_DIR�USER_CONFIG_DIRS)�PathNotFound�TracerError)�ApplicationsCollection)�_)�	Processes)�System)�SystemdDbus)�	lru_cacheNc@s�eZdZedd�ege�Zddddddd	�Zed
ZdZ	e
dd
��Ze
dd��Ze
dd��Z
edd��Zedd��Ze
ifdd��Ze
dd��ZdS)�ApplicationscCs|dS)Nz/applications.xml�)�xrr�"/usr/lib/python3.6/applications.py�<lambda>%szApplications.<lambda>ZdaemonZstaticZsession�applicationZerasedZ	undefined)�DAEMON�STATIC�SESSION�APPLICATIONZERASED�UNDEFrNcCsZtjstj�x0tjD]&}|j|krd|kr0|Stj|j�SqWt|tjddddd��S)N�renamerF)�name�type�helper�note�ignore)r�_apps�_load_definitionsr�findr�Application�TYPES)Zapp_name�apprrrr"2s
zApplications.findcCstjstj�tjS)N)rr r!rrrr�allDszApplications.allcCsbt�t_xTtjD]J}ytj|�Wqtk
rX}ztjj|�t	krH|�WYdd}~XqXqWdS)N)
r	rr �DEFINITIONS�_loadr�os�path�dirnamer)�file�exrrrr!KszApplications._load_definitionscCsy(t|d��}tj|j��}WdQRXWnPtk
rDtd��Yn6tk
rx}zdj||�}t|��WYdd}~XnXx�|j	d�D]�}|j
|�x||jD]r}|jdkr�t
|jj��}tj|�|jdkr�|j
|�x6|jD],}	t
|	jj��}
t
|jj��}tj|
|�q�Wq�Wq�WdS)N�rrzUnable to parse {0}
Hint: {1}�applicationsr%�group)�openrZparseString�read�IOErrorrr�formatrZgetElementsByTagName�_remove_unwanted_children�
childNodesZnodeName�dictZ
attributes�itemsr�_append_application)�clsr,�fZxmldocr-�msgr/�childZattrsr%Z	app_attrsZgroup_attrsrrrr(Ts(




zApplications._loadcCs*x$|jD]}|j|jkr|j|�qWdS)N)r6ZnodeTypeZELEMENT_NODEZremoveChild)r:Znoder=rrrr5msz&Applications._remove_unwanted_childrencCs�t|�}|j|�|tjkr:tjj|�}tj|j|�nD|jdtj�|jdtj|��|jdd�|jdd�tjj|�dS)NrrrrF)	r#�updaterr �index�
setdefault�DEFAULT_TYPE�_helper�append)Z
default_attrsZspecific_attrsr�irrrr9ss

z Applications._append_applicationcCsj|jtjdkr6tj�dkr(dj|j�Sdj|j�Sn0|jtjdkrNtd�S|jtjdkrftd�SdS)	Nr�systemdzsystemctl restart {0}zservice {0} restartrz%You will have to reboot your computerrz'You will have to log out & log in again)rrr$r�init_systemr4rr
)r%rrrrB�szApplications._helper)�__name__�
__module__�__qualname__�maprrr'r$rAr �staticmethodr"r&r!�classmethodr(r5r9rBrrrrr#s"	rc@s�eZdZdZeZdZdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zedd��Zeedd�dd���Zedd��Zeedd�d d!���Zed"d#��Zed$d%��Zed&d'��Zed(d)��Zed*d+��ZdZdS),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

	NcCs||_d|_dS)N)�_attributes�_cached_name)�selfZattributes_dictrrr�__init__�szApplication.__init__cCst|t�o|j|jkS)N)�
isinstancer#r)rO�otherrrr�__eq__�szApplication.__eq__cCs|j|�S)N)rS)rOrRrrr�__ne__�szApplication.__ne__cCs
t|j�S)N)�hashr)rOrrr�__hash__�szApplication.__hash__cCs
|j|S)N)rM)rO�itemrrr�__getattr__�szApplication.__getattr__cCs
t|j�S)N)�lenrM)rOrrr�__len__�szApplication.__len__cCs
||jkS)N)rM)rOrWrrr�__contains__�szApplication.__contains__cCsd|jjd|jddS)N�<z: r�>)�	__class__rGrM)rOrrr�__str__�szApplication.__str__cCs|j�S)N)r_)rOrrr�__repr__�szApplication.__repr__cCs|jj||�dS)N)rMr@)rO�key�valuerrrr@�szApplication.setdefaultcCs t|t�r|j}|jj|�dS)N)rQr#rMr>)rO�valuesrrrr>�s
zApplication.updatecCs|jo|jdjS)Nr)�	instances�is_interpreted)rOrrrre�szApplication.is_interpreted)�maxsizecCs.|jjd�r|jjd�rdS|jo,|jdjS)Nzssh-z-sessionTr)r�
startswith�endswithrd�
is_session)rOrrrri�szApplication.is_sessioncCsD|jdtjdkr|jdS|jr.tjdS|jr>tjdStjS)Nrrrr)rMrr$ri�
is_servicerA)rOrrrr�s


zApplication.typecCs$tj�dkr t�jdj|j��SdS)NrEz{0}.service)rrFr
Zunit_path_from_idr4r)rOrrrrj�szApplication.is_servicecCsL|jdptj|�}tj�dkrH|jtjdkrH|rH|jd�rHd|}|S)Nr�rootrzsudo )rMrrBr�userrr$rg)rOrrrrr�s
zApplication.helpercCs|js
dSttjd|j��S)Nz\{.*\})r�bool�re�search)rOrrr�helper_contains_formating�sz%Application.helper_contains_formatingcCs|js
dSttjd|j��S)Nz\{NAME\})rrmrnro)rOrrr�helper_contains_name�sz Application.helper_contains_namecCsTg}|jrP|js|j|j�n2x0|jD]&}|j|jj|j|j|j|jd��q&W|S)ab
		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.
		)�NAMEZPNAMEZPID�EXE)rrprC�affected_instancesr4r�pidZexe)rO�helpers�processrrrrv�s	
zApplication.helperscs�jj�j�fdd��S)zo
		Return collection of processes with same name as application.
		I.e. running instances of the application
		cs�jd|j�|jgkS)Nr)rMr�	real_name)rw)rOrrrsz'Application.instances.<locals>.<lambda>)�processes_factoryr&Zfiltered)rOr)rOrrds
zApplication.instances)rGrHrI�__doc__rryrMrPrSrTrVrXrZr[r_r`r@r>�propertyrerrirrjrrprqrvrdrtrrrrr#�s4
	r#c@s eZdZedd��Zdd�ZdS)�AffectedApplicationcCs|js|j�|_|jS)N)rN�_name)rOrrrr s
zAffectedApplication.namecCs�tj�dkr�t�}y|jdj}Wntk
r:d}YnX|r�|jr�|j|�r�|j|d�s�|j|d�}|r�t	j
d|�r�t	jdd|�S|jr�|jdj
S|jdS)NrErZPAMName�Idz
\.service$�r)rrFr
rdru�
IndexErrorZunit_path_from_pidZhas_service_property_from_pidZget_unit_property_from_pidrnro�subrerxrM)rOZbusrur~rrrr}(s
zAffectedApplication._nameN)rGrHrIr{rr}rrrrr|sr|)Z
__future__rZxml.domrZxml.parsers.expatrZtracer.pathsrrZtracer.resources.exceptionsrrZtracer.resources.collectionsr	Ztracer.resources.langr
Ztracer.resources.processesrZtracer.resources.systemrZtracer.resources.SystemdDbusr
Ztracer.resources.pycomprr)rn�objectrr#r|rrrr�<module>s p

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