HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/psutil/__pycache__/_common.cpython-310.pyc
o

;j�b�
@s(dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
Z
ddlmZddlmZzddlm
Z
WneyKdZ
YnwzddlmZWney_dZYnwee�d��Ze�Zgd	�Zejd
kZejdkZej�d�Zej�d
�ZeZej�d�Zej�d�Zej�d�Z ep�ep�e Z!ej�d�Z"ej�d�Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0d Z1d!Z2d"Z3d#Z4d$Z5d%Z6d&Z7d'Z8d(Z9d)Z:d*Z;d+Z<d,Z=Gd-d.�d.ej>�Z?e@��Ae?jB�Gd/d0�d0ej>�ZCe@��AeCjB�e�D�ZEe�F�ZGe
e
egeegfe
e
gegfe
gegfe
e
gegfe
gegfe
e
geegfe
geegfe
geegfd1�ZHe
du�rOeH�Ae
gegfe
gegfd2��edu�rce"�sceH�Ad3egeegfi�Gd4d5�d5eI�ZJGd6d7�d7eJ�ZKGd8d9�d9eK�ZLGd:d;�d;eJ�ZMGd<d=�d=eJ�ZNdsd>d?�ZOd@dA�ZPdBdC�ZQdDdE�ZRdFdG�ZSdHdI�ZTdJdK�ZUdLdM�ZVdNdO�ZWdsdPdQ�ZXdRdS�ZYdTdU�ZZGdVdW�dW�Z[dXdY�Z\e[�Z]e]j^e\_^e]j_e\__dZZ`d[d\�Zad]d^�Zbeebfd_d`�Zcefdadb�Zddtddde�Zedfdg�Zfdhdi�ZgePejhfdjdk��Zidudmdn�Zjddlejhfdodp�Zkdqdr�ZldS)vz�Common objects shared by __init__.py and _ps*.py modules.

Note: this module is imported by setup.py, so it should not import
psutil or third-party modules.
�N)�AF_INET)�
SOCK_DGRAM)�SOCK_STREAM)�AF_INET6)�AF_UNIX�PSUTIL_DEBUG)?�FREEBSD�BSD�LINUX�NETBSD�OPENBSD�MACOS�OSX�POSIX�SUNOS�WINDOWS�
CONN_CLOSE�CONN_CLOSE_WAIT�CONN_CLOSING�CONN_ESTABLISHED�CONN_FIN_WAIT1�CONN_FIN_WAIT2�
CONN_LAST_ACK�CONN_LISTEN�	CONN_NONE�
CONN_SYN_RECV�
CONN_SYN_SENT�CONN_TIME_WAIT�NIC_DUPLEX_FULL�NIC_DUPLEX_HALF�NIC_DUPLEX_UNKNOWN�STATUS_DEAD�STATUS_DISK_SLEEP�STATUS_IDLE�
STATUS_LOCKED�STATUS_RUNNING�STATUS_SLEEPING�STATUS_STOPPED�STATUS_SUSPENDED�STATUS_TRACING_STOP�STATUS_WAITING�STATUS_WAKE_KILL�
STATUS_WAKING�
STATUS_ZOMBIE�
STATUS_PARKED�ENCODING�
ENCODING_ERRSr�	conn_tmap�deprecated_method�
isfile_strict�memoize�parse_environ_block�path_exists_strict�
usage_percent�
supports_ipv6�sockfam_to_enum�socktype_to_enum�wrap_numbers�	open_text�open_binary�cat�bcat�bytes2human�conn_to_ntuple�debug�hilite�term_supports_colors�print_color�posix�nt�linux�darwin)ZfreebsdZmidnightbsdZopenbsdZnetbsd)ZsunosZsolaris�aixZrunningZsleepingz
disk-sleep�stoppedztracing-stopZzombieZdeadz	wake-killZwakingZidle�lockedZwaitingZ	suspendedZparkedZESTABLISHEDZSYN_SENTZSYN_RECVZ	FIN_WAIT1Z	FIN_WAIT2Z	TIME_WAITZCLOSEZ
CLOSE_WAITZLAST_ACKZLISTENZCLOSINGZNONEc@seZdZdZdZdZdS)�	NicDuplex��rN)�__name__�
__module__�__qualname__rrr �rSrS�B/opt/saltstack/salt/lib/python3.10/site-packages/psutil/_common.pyrMzsrMc@seZdZdZdZdS)�BatteryTime������N)rPrQrRZPOWER_TIME_UNKNOWNZPOWER_TIME_UNLIMITEDrSrSrSrTrU�srU)�allZtcpZtcp4ZudpZudp4ZinetZinet4Zinet6)Ztcp6Zudp6Zunixc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�ErrorzQBase exception class. All other psutil exceptions inherit
    from this one.
    �psutilcCs>t��}|D]}t||d�}|s|dkr|dkr|||<q|S)N�pidr)�collections�OrderedDict�getattr)�self�attrs�info�name�valuerSrSrT�	_infodict�s�zError._infodictcCsR|�d�}|rd�d�dd�|��D���}nd}d�dd�t|dd	�|fD��S)
N)r[�ppidrbz({})�, cS�g|]\}}|�d|���qS��=rS��.0�k�vrSrSrT�
<listcomp>��z!Error.__str__.<locals>.<listcomp>� cSsg|]}|r|�qSrSrS)rk�xrSrSrTrn�s�msg�)rd�format�join�itemsr^�r_ra�detailsrSrSrT�__str__�s
� z
Error.__str__cCs8|�d�}d�dd�|��D��}d|jj�d|�d�S)N)r[rerb�secondsrrrfcSrgrhrSrjrSrSrTrn�roz"Error.__repr__.<locals>.<listcomp>zpsutil.�(�))rdrurv�	__class__rPrwrSrSrT�__repr__�s
zError.__repr__N)rPrQrR�__doc__rdryr~rSrSrSrTrY�srYc@�&eZdZdZdZddd�Zdd�ZdS)	�
NoSuchProcesszXException raised when a process with a certain PID doesn't
    or no longer exists.
    rZNcC�$t�|�||_||_|pd|_dS)Nzprocess no longer exists�rY�__init__r[rbrr�r_r[rbrrrSrSrTr���
zNoSuchProcess.__init__cC�|j|j|j|jffS�N�r}r[rbrr�r_rSrSrT�
__reduce__��zNoSuchProcess.__reduce__�NN�rPrQrRrr�r�rSrSrSrTr��s

r�c@r�)	�
ZombieProcessa1Exception raised when querying a zombie process. This is
    raised on macOS, BSD and Solaris only, and not always: depending
    on the query the OS may be able to succeed anyway.
    On Linux all zombie processes are querable (hence this is never
    raised). Windows doesn't have zombie processes.
    rZNcCs$t�||||�||_|pd|_dS)Nz"PID still exists but it's a zombie)r�r�rerr)r_r[rbrerrrSrSrTr��szZombieProcess.__init__cCs|j|j|j|j|jffSr�)r}r[rbrerrr�rSrSrTr��szZombieProcess.__reduce__�NNNr�rSrSrSrTr��s

r�c@r�)	�AccessDeniedz@Exception raised when permission to perform an action is denied.rZNcCr�)Nrsr�r�rSrSrTr��r�zAccessDenied.__init__cCr�r�r�r�rSrSrTr�r�zAccessDenied.__reduce__r�r�rSrSrSrTr��s

r�c@r�)	�TimeoutExpiredzWRaised on Process.wait(timeout) if timeout expires and process
    is still alive.
    rZNcCs.t�|�||_||_||_d|�d�|_dS)Nztimeout after z seconds)rYr�rzr[rbrr)r_rzr[rbrSrSrTr�s

zTimeoutExpired.__init__cCr�r�)r}rzr[rbr�rSrSrTr�r�zTimeoutExpired.__reduce__r�r�rSrSrSrTr�s

r�cCs@z
t|�|d}Wn
tyYdSw|durt||�}|S)z5Calculate percentage usage of 'used' against 'total'.�dgN)�float�ZeroDivisionError�round)�used�totalZround_�retrSrSrTr7s�
r7cs2t�����fdd��}�fdd�}i�||_|S)a�A simple memoize decorator for functions supporting (hashable)
    positional arguments.
    It also provides a cache_clear() function for clearing the cache:

    >>> @memoize
    ... def foo()
    ...     return 1
        ...
    >>> foo()
    1
    >>> foo.cache_clear()
    >>>

    It supports:
     - functions
     - classes (acts as a @singleton)
     - staticmethods
     - classmethods

    It does NOT support:
     - methods
    c
sn|tt|����f}z�|WSty6z�|i|��}�|<W|YSty5}z|d�d}~wwwr�)�	frozenset�sortedrv�KeyError�	Exception)�args�kwargs�keyr��err��cache�funrSrT�wrapper?s
����zmemoize.<locals>.wrappercs���dS)zClear cache.N)�clearrS)r�rSrT�cache_clearK�zmemoize.<locals>.cache_clear)�	functools�wrapsr�)r�r�r�rSr�rTr4'sr4cs6t����fdd��}dd�}dd�}||_||_|S)a�A memoize decorator which is disabled by default. It can be
    activated and deactivated on request.
    For efficiency reasons it can be used only against class methods
    accepting no arguments.

    >>> class Foo:
    ...     @memoize
    ...     def foo()
    ...         print(1)
    ...
    >>> f = Foo()
    >>> # deactivated (default)
    >>> foo()
    1
    >>> foo()
    1
    >>>
    >>> # activated
    >>> foo.cache_activate(self)
    >>> foo()
    1
    >>> foo()
    >>> foo()
    >>>
    c
s�z|j�}W|Sty&z�|�WYSty%}z|d�d}~wwtyWz�|�}WntyA}z|d�d}~wwz	||j�<WY|StyVYY|Swwr�)�_cache�AttributeErrorr�r�)r_r�r��r�rSrTr�os2��������z'memoize_when_activated.<locals>.wrappercSs
i|_dS)zsActivate cache. Expects a Process instance. Cache will be
        stored as a "_cache" instance attribute.
        N)r���procrSrSrT�cache_activate�s
z.memoize_when_activated.<locals>.cache_activatecSs z|`WdStyYdSw)zDeactivate and clear cache.N)r�r�r�rSrSrT�cache_deactivate�s

�z0memoize_when_activated.<locals>.cache_deactivate)r�r�r�r�)r�r�r�r�rSr�rT�memoize_when_activatedTsr�cCs>zt�|�}Wnty�tyYdSwt�|j�S)z�Same as os.path.isfile() but does not swallow EACCES / EPERM
    exceptions, see:
    http://mail.python.org/pipermail/python-dev/2012-June/120787.html.
    F)�os�stat�PermissionError�OSError�S_ISREG�st_mode)�path�strSrSrTr3�s�r3cCs4zt�|�WdSty�tyYdSw)z�Same as os.path.exists() but does not swallow EACCES / EPERM
    exceptions. See:
    http://mail.python.org/pipermail/python-dev/2012-June/120787.html.
    FT)r�r�r�r�)r�rSrSrTr6�s��r6cCsjtjrtdur	dSz!t�ttj��}|�d�Wd�WdS1s#wYWdSty4YdSw)z2Return True if IPv6 is supported on this platform.NF)z::1rT)�socket�has_ipv6rr�bindr�)�sockrSrSrTr8�s
���r8cCsxi}d}t}	|�d|�}||kr	|S|�d||�}||kr7|||�}||d|�}|r3|��}|||<|d}q)zCParse a C environ block of environment variables into a dictionary.rT�rirO)r�find�upper)�datar��posZWINDOWS_Znext_posZ	equal_posr�rcrSrSrTr5�s"��r5cC�$zt�|�WSty|YSw)z�Convert a numeric socket family value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    )r��
AddressFamily�
ValueError��numrSrSrTr9��
�r9cCr�)zConvert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    )r��
SocketKindr�r�rSrSrTr:�r�r:c		Cs�ddlm}|tjthvr|r|j|�}|r|j|�}|tjkr-|tthvr-|�|t�}nt}t	|�}t
|�}|durE|�||||||�S|�|||||||�S)z2Convert a raw connection tuple to a proper ntuple.rO)�_ntuplesN)
rsr�r�rr�addrr�getrr9r:�pconnZsconn)	�fdZfam�type_�laddr�raddr�statusZ
status_mapr[ZntprSrSrTrA�s

rAcCsxddl}|jr
|jsdS|jtjkr#t|j|j�d|j��dd�j�S|jtj	kr:t|j
|j�d|j��dd�j�SdS)zbGiven the address ntuple returned by ``net_if_addrs()``
    calculates the broadcast address.
    rN�/F)�strict)�	ipaddress�address�netmask�familyr�r�str�IPv4Network�broadcast_addressr�IPv6Network)r�r�rSrSrT�broadcast_addr
s$�����r�cs�fdd�}|S)z�A decorator which can be used to mark a method as deprecated
    'replcement' is the method name which will be called instead.
    cs>|j�d��d��|jdur�|_t�|���fdd��}|S)Nz*() is deprecated and will be removed; use z
() insteadcs$tj�tdd�t|��|i|��S)NrN)�category�
stacklevel)�warnings�warn�DeprecationWarningr^)r_r�r�)rr�replacementrSrT�inner-sz/deprecated_method.<locals>.outer.<locals>.inner)rPrr�r�)r�r��r�)rrrT�outer%s��
z deprecated_method.<locals>.outerrS)r�r�rSr�rTr2 sr2c@sBeZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	d
S)�_WrapNumberszNWatches numbers so that they don't overflow and wrap
    (reset to zero).
    cCs t��|_i|_i|_i|_dSr�)�	threading�Lock�lockr��	reminders�
reminder_keysr�rSrSrTr�<s

z_WrapNumbers.__init__cCsX||jvsJ�||jvsJ�||jvsJ�||j|<t�t�|j|<t�t�|j|<dSr�)r�r�r�r\�defaultdict�int�set)r_�
input_dictrbrSrSrT�	_add_dictBs
z_WrapNumbers._add_dictcCs\|j|}t|���t|���}|D]}|j||D]}|j||=q|j||=qdS)z�In case the number of keys changed between calls (e.g. a
        disk disappears) this removes the entry from self.reminders.
        N)r�r��keysr�r�)r_r�rb�old_dictZ	gone_keysZgone_key�remkeyrSrSrT�_remove_dead_remindersJs
�z#_WrapNumbers._remove_dead_remindersc
	Cs||jvr
|�||�|S|�||�|j|}i}|D]\}||}z||}Wn
ty5|||<Yqwg}tt|��D]3}	||	}
||	}||	f}|
|kre|j|||7<|j||�|�|�	|
|j||�q>t
|�||<q||j|<|S)zlCache dict and sum numbers which overflow and wrap.
        Return an updated copy of `input_dict`.
        )r�r�r�r��range�lenr�r��add�append�tuple)
r_r�rbr�Znew_dictr�Zinput_tupleZ	old_tuple�bits�iZinput_value�	old_valuer�rSrSrT�runUs4

�
z_WrapNumbers.runNcCs�|j�:|dur|j��|j��|j��n|j�|d�|j�|d�|j�|d�Wd�dSWd�dS1s@wYdS)z>Clear the internal cache, optionally only for function 'name'.N)r�r�r�r�r��pop)r_rbrSrSrTr�|s

�"�z_WrapNumbers.cache_clearcCs:|j�|j|j|jfWd�S1swYdS)z5Return internal cache dicts as a tuple of 3 elements.N)r�r�r�r�r�rSrSrT�
cache_info�s$�z_WrapNumbers.cache_infor�)
rPrQrRrr�r�r�r�r�rrSrSrSrTr�7s
'r�cCs6tj�t�||�Wd�S1swYdS)z�Given an `input_dict` and a function `name`, adjust the numbers
    which "wrap" (restart from zero) across different calls by adding
    "old value" to "new value" and return an updated dict.
    N)�_wnr�r�)r�rbrSrSrTr;�s
$�r;i�cCst|dtd�S)N�rb)�	buffering)�open�FILE_READ_BUFFER_SIZE)�fnamerSrSrTr=��r=cCsHt|tttd�}zt|_W|StyY|Sty#|���w)zaOpen a file in text mode by using the proper FS encoding and
    en/decoding error handlers.
    )r�encoding�errors)rrr/r0�_CHUNK_SIZEr�r��close)rZfobjrSrSrTr<�s ����r<cCs�|tur||��}|��Wd�S1swYdSz||��
}|��Wd�WS1s3wYWdStyE|YSw)z�Read entire file content and return it as a string. File is
    opened in text mode. If specified, `fallback` is the value
    returned in case of error, either if the file does not exist or
    it can't be read().
    N)�_DEFAULT�readr�)r�fallback�_open�frSrSrTr>�s
$�
(��r>cCst||td�S)z,Same as above but opens file in binary mode.)rr)r>r=)rrrSrSrTr?�sr?�%(value).1f%(symbol)scCs�d}i}t|dd��D]\}}d|dd>||<qt|dd��D]}t|�||kr<t|�||}|t�Sq#|t|d|d�S)z�Used by various scripts. See: https://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/?in=user-4178764.

    >>> bytes2human(10000)
    '9.8K'
    >>> bytes2human(100001221)
    '95.4M'
    )	�B�K�M�G�T�P�E�Z�YrON�
r)�symbolrc)�	enumerate�reversed�absr��locals�dict)�nrt�symbols�prefixr��srrcrSrSrTr@�s�r@cCstjdjS)z+Return updated psutil.PROCFS_PATH constant.rZ)�sys�modulesZPROCFS_PATHrSrSrSrT�get_procfs_path�r�r)cCs|jttd�S)N)r	r
)�decoder/r0)r&rSrSrTr*�rr*cCs:t|d�r	|��sdSz|��WdStyYdSw)N�isattyFT)�hasattrr+�filenor���filerSrSrTrD�s
��rDFcCs�t�s|Sg}tddddddddd	d
�	}d|d<z||}Wnty6d
|�dt|�����}t|�d�w|�|�|rC|�d�dd�|��d|�d�S)z*Return an highlighted version of 'string'.Z34Z33Z30Z32Z37Z36Z91Z35Z93)	Zblue�brownZdarkgrey�greenZgreyZ	lightblue�redZviolet�yellowZ29N�invalid color z; choose amongst �1z[�;�mz)rDr"r��listr�r�r�ru)r&�color�bold�attr�colorsrrrSrSrTrC	s2�
�

rCc	Cst�st||d�dStrtt|||�|d�dSddl}d}|jjj}|jjj}t	ddddd�}||d<z||}Wnt
ySd	|�d
t|�����}	t
|	�d�w|r^|dkr^|d7}|tjurednd
}
|j|_||
�}|||�zt||d�W|||�dS|||�w)z$Print a colorized version of string.r.rN�rN��)r1r2r0r3r4z; choose between �i�i����)rD�printrrC�ctypesZwindllZKernel32�GetStdHandle�SetConsoleTextAttributer"r�r8r�r�r'�stderr�c_ulong�restype)r&r9r:r/rBZ
DEFAULT_COLORrCrDr<rrZ	handle_id�handlerSrSrTrE%s:
�
��
�
rEcCsxtr:ddl}|�|��j�\}}}}}t|t�r(t|t�r#d|��}nd|��}td|�d|�d|��t	j
d�dSdS)z@If PSUTIL_DEBUG env var is set, print a debug message to stderr.rNz	ignoring zpsutil-debug [�:z]> r.)r�inspectZgetframeinfo�currentframe�f_back�
isinstancer�r�rAr'rE)rrrJr�lineno�_�_lines�_indexrSrSrTrBMs�



��rBr�)r)NF)mrr\�enumr�r�r�r�r'r�r�rrrr�ImportErrorr�bool�getenvr�objectr
�__all__rbrr�platform�
startswithr
r
rrrrr	rZAIXr%r&r"r'r)r-r!r+r,r#r$r*r(r.rrrrrrrrrrrr�IntEnumrM�globals�update�__members__rU�getfilesystemencodingr/�getfilesystemencodeerrorsr0r1r�rYr�r�r�r�r7r4r�r3r6r8r5r9r:rAr�r2r�r;rr�rrr=r<r>r?r@r)r*�stdoutrDrCrErBrSrSrSrT�<module>s���
"
		

�


�!
-G


W	

	


�(