File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/ps.cpython-310.pyc
o
�N�g�I � @ s� d Z ddlZddlZddlZddlZddlZddlmZm Z zddl
Z
dZW n ey1 dZY nw dd� Z
dd � Zd
d� Zdd
� Zdd� Zdd� Zdd� ZdHdd�Zdd� ZdIdd�ZdJdd�ZdKdd �ZdLd!d"�ZdMd$d%�ZdNd&d'�Zd(d)� Zd*d+� ZdNd,d-�Zd.d/� ZdNd0d1�Z d2d3� Z!d4d5� Z"dId6d7�Z#dId8d9�Z$dId:d;�Z%d<d=� Z&d>d?� Z'ej(j)j*�+d@�dAd@� �Z,ej(j)j*�+dB�dCdB� �Z-dDdE� Z.dFdG� Z/dS )Oz�
A salt interface to psutil, a system and process library.
See http://code.google.com/p/psutil.
:depends: - python-utmp package (optional)
� N)�CommandExecutionError�SaltInvocationErrorTFc C s t sdS dS )N)FzCThe ps module cannot be loaded: python module psutil not installed.T)�
HAS_PSUTIL� r r �C/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/ps.py�__virtual__ s r c C �4 z
t jj�| �� �W S tjtjfy g Y S w )zq
Returns the cmdline of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
)�salt�utils�data�decodeZcmdline�psutil�
NoSuchProcess�AccessDenied��procr r r �_get_proc_cmdline! �
�r c C �2 z
t jj�| �� �W S tjtjfy Y dS w )zu
Returns the create_time of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
N)r r
r r �create_timer
r r r r r r �_get_proc_create_time- �
�r c C r )zn
Returns the name of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
)r r
r r �namer
r r r r r r �_get_proc_name9 r r c C r )zp
Returns the status of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
N)r r
r r �statusr
r r r r r r �_get_proc_statusE r r c
C s4 z
t jj�| �� �W S tjtjtfy Y dS w )zr
Returns the username of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
N) r r
r r �usernamer
r r �KeyErrorr r r r �_get_proc_usernameQ s
�r c C s | j S )zm
Returns the pid of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
)�pidr r r r �
_get_proc_pid] s r � � c C s� g }i }t �� D ]5}zt �|�}W n
t jy Y qw z|�� dd� \}}W n t jy6 d }}Y nw || ||<