%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__/applications.cpython-39.pyc

a

"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�A/usr/lib/python3.9/site-packages/tracer/resources/applications.py�<lambda>%�zApplications.<lambda>�daemonZstaticZsession�applicationZerasedZ	undefined)�DAEMON�STATIC�SESSION�APPLICATIONZERASED�UNDEFrNcCsZtjst��tjD]*}|j|krd|vr.|n
t�|j�Sqt|tjddddd��S)N�renamerF)�name�type�helper�note�ignore)r�_apps�_load_definitionsr�findr�Application�TYPES)Zapp_name�apprrrr$2s

�zApplications.findcCstjst��tjS�N)rr"r#rrrr�allDszApplications.allcCs`t�t_tjD]L}zt�|�WqtyX}z tj�|�t	vrD|�WYd}~qd}~00qdSr()
r	rr"�DEFINITIONS�_loadr�os�path�dirnamer)�file�exrrrr#Ks
zApplications._load_definitionsc
Cs"z<t|d��}t�|���}Wd�n1s00YWnPtyVtd��Yn8ty�}z d�||�}t|��WYd}~n
d}~00|�	d�D]�}|�
|�|jD]n}|jdkr�t
|j���}t�|�|jdkr�|�
|�|jD],}	t
|	j���}
t
|j���}t�|
|�q�q�q�dS)N�rrzUnable to parse {0}
Hint: {1}�applicationsr'�group)�openrZparseString�read�IOErrorrr�formatrZgetElementsByTagName�_remove_unwanted_children�
childNodesZnodeName�dictZ
attributes�itemsr�_append_application)�clsr/�fZxmldocr0�msgr2�child�attrsr'Z	app_attrsZgroup_attrsrrrr+Ts(0






zApplications._loadcCs&|jD]}|j|jkr|�|�qdSr()r9ZnodeTypeZELEMENT_NODEZremoveChild)r=Znoder@rrrr8ms
z&Applications._remove_unwanted_childrencCs�t|�}|�|�|tjvr:tj�|�}tj|�|�nD|�dtj�|�dt�|��|�dd�|�dd�tj�|�dS)Nrrr r!F)	r%�updaterr"�index�
setdefault�DEFAULT_TYPE�_helper�append)Z
default_attrsZspecific_attrsr�irrrr<ss

z Applications._append_applicationcCsj|jtjdkr6t��dkr(d�|j�Sd�|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_systemr7rr
)r'rrrrF�szApplications._helper)�__name__�
__module__�__qualname__�maprrr*r&rEr"�staticmethodr$r)r#�classmethodr+r8r<rFrrrrr#s0�




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|_dSr()�_attributes�_cached_name)�selfZattributes_dictrrr�__init__�szApplication.__init__cCst|t�o|j|jkSr()�
isinstancer%r�rS�otherrrr�__eq__�szApplication.__eq__cCs|�|�Sr()rXrVrrr�__ne__�szApplication.__ne__cCs
t|j�Sr()�hashr�rSrrr�__hash__�szApplication.__hash__cCs
|j|Sr(�rQ�rS�itemrrr�__getattr__�szApplication.__getattr__cCs
t|j�Sr()�lenrQr[rrr�__len__�szApplication.__len__cCs
||jvSr(r]r^rrr�__contains__�szApplication.__contains__cCsd|jjd|jddS)N�<z: r�>)�	__class__rKrQr[rrr�__str__�szApplication.__str__cCs|��Sr()rgr[rrr�__repr__�szApplication.__repr__cCs|j�||�dSr()rQrD)rS�key�valuerrrrD�szApplication.setdefaultcCs t|t�r|j}|j�|�dSr()rUr%rQrB)rS�valuesrrrrB�s
zApplication.updatecCs|jo|jdjS)Nr)�	instances�is_interpretedr[rrrrm�szApplication.is_interpreted)�maxsizecCs.|j�d�r|j�d�rdS|jo,|jdjS)Nzssh-z-sessionTr)r�
startswith�endswithrl�
is_sessionr[rrrrq�szApplication.is_sessioncCsD|jdtjdkr|jdS|jr.tjdS|jr>tjdStjS)Nrrrr)rQrr&rq�
is_servicerEr[rrrr�s


zApplication.typecCs$t��dkr t��d�|j��SdS)NrIz{0}.service)rrJr
Zunit_path_from_idr7rr[rrrrr�szApplication.is_servicecCsJ|jdpt�|�}t��dkrF|jtjdkrF|rF|�d�sFd|}|S)Nr�rootrzsudo )rQrrFr�userrr&ro)rSrrrrr�s
zApplication.helpercCs|js
dStt�d|j��S)Nz\{.*\}�r�bool�re�searchr[rrr�helper_contains_formating�sz%Application.helper_contains_formatingcCs|js
dStt�d|j��S)Nz\{NAME\}rur[rrr�helper_contains_name�sz Application.helper_contains_namec	CsPg}|jrL|js|�|j�n.|jD]&}|�|jj|j|j|j|jd��q$|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.
		)�NAMEZPNAMEZPIDZEXE)rryrG�affected_instancesr7r�pidZexe)rS�helpers�processrrrr~�s	

�
zApplication.helperscs�j����fdd��S)zo
		Return collection of processes with same name as application.
		I.e. running instances of the application
		cs�jd|��|jfvS)Nr)rQr�	real_name)rr[rrrrz'Application.instances.<locals>.<lambda>)�processes_factoryr)Zfilteredr[rr[rrls

�zApplication.instances)rKrLrM�__doc__rr�rQrTrXrYr\r`rbrcrgrhrDrB�propertyrmrrqrrrrryrzr~rlr|rrrrr%�sF






r%c@s eZdZedd��Zdd�ZdS)�AffectedApplicationcCs|js|��|_|jSr()rR�_namer[rrrr s
zAffectedApplication.namecCs�t��dkr�t�}z|jdj}Wnty8d}Yn0|r�|jr�|�|�r�|�|d�s�|�|d�}|r�t	�
d|�r�t	�dd|�S|jr�|jdj
S|jdS)NrIrZPAMName�Idz
\.service$�r)rrJr
rlr}�
IndexErrorZunit_path_from_pidZhas_service_property_from_pidZget_unit_property_from_pidrwrx�subrmr�rQ)rSZbusr}r�rrrr�(s
zAffectedApplication._nameN)rKrLrMr�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,rw�objectrr%r�rrrr�<module>s p

Zerion Mini Shell 1.0