관리-도구
편집 파일: _common.cpython-37.pyc
B �=�_jf � N @ s8 d Z ddlmZmZ ddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl mZ ddl mZ ddlmZ ddlmZ ddlmZ ydd lmZ W n ek r� dZY nX ydd lmZ W n ek r� dZY nX e jdk�rddlZndZe jd dkZd ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZgNZejd[kZejd\kZe j�d]�Ze j�d^�Z e Z!e j�d_�Z"e j�d`�Z#e j�da�Z$e"�pe#�pe$Z%e j�db�Z&e j�dc�Z'ddZ(deZ)dfZ*dgZ+dhZ,diZ-djZ.dkZ/dlZ0dmZ1dnZ2doZ3dpZ4dqZ5drZ6dsZ7dtZ8duZ9dvZ:dwZ;dxZ<dyZ=dzZ>d{Z?d|Z@d}ZAedk�r�d~ZBdZCdZDn G d�d�� d�ejE�ZFeG� �HeFjI� edk�r�d�ZJd�ZKn G d�d�� d�ejE�ZLeG� �HeLjI� e �M� ZNe�sd�ZOn2ye �P� ZOW n$ eQk �rH e�r@d�nd�ZOY nX edHd�d�d�d�d�d�g�ZRedDd�d�d�d�g�ZSedBd�d�d�d�d�d�g�ZTedCd�d�d�d�d�d�g�ZUedEd�d�d�d�d�d�d�d�g�ZVedId�d�d�d�d�g�ZWed@d�d�d�d�d�d�d�g�ZXedFd�d�d�d�d�g�ZYedGd�d�d�d�g�ZZedAd�d�d�d�g�Z[ed�d�d�d�g�Z\ed�d�d�d�d�g�Z]ed�d�d�d�g�Z^ed�d�d�g�Z_ed8d�d�d�d�g�Z`ed=d�d�g�Zaed>d�d�d�g�Zbed?d�d�d�g�Zced:d�d�d�g�Zded;d�d�d�d�g�Zeed<d�d�g�Zfed9d�d�g�Zged7d�d�d�d�d�d�g�Zhed�d�d�g�ZieeegeegfeegegfegegfeegegfegegfeegeegfegeegfegeegfdלZjedk �r�ej�Hegegfegegfd� edk �r�ej�Hd�egeegfi� G d�dۄ d�ek�ZlG d�d݄ d�el�ZmG d�d߄ d�em�ZnG d�d� d�el�ZoG d�d� d�el�Zp�dd�dP�Zqd�dM� Zrd�d� Zsd�dL� Ztd�dO� Zuerd�dQ� �Zvd�dN� Zwd�dR� Zxd�dS� Zy�dd�dV�Zzd�dK� Z{G d�d� d�Z|d�dT� Z}e|� Z~e~je}_e~j�e}_�d�d� Z�d�d�� Z��dd�dU�Z�d�d�� Z�e�r�d�d�� Z�nd�d�� Z�ere j�fd�dY��Z��d�d dX�Z�dd�e j�f�ddZ�Z�e�e���dd���r*ddl�Z��ddW� Z�n �ddW� Z�dS ( z9Common objects shared by __init__.py and _ps*.py modules.� )�division�print_functionN)�defaultdict)� namedtuple)�AF_INET)� SOCK_DGRAM)�SOCK_STREAM)�AF_INET6)�AF_UNIX)� � r �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 �pconn� pcputimes�pctxsw�pgids�pio�pionice� popenfile�pthread�puids�sconn� scpustats�sdiskio� sdiskpart� sdiskusage�snetio�snicaddr� snicstats�sswap�suser� 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�bytes2human�conn_to_ntuple�debug�hilite�term_supports_colors�print_color�posix�nt�linux�darwin�freebsdZopenbsdZnetbsd)�sunos�solaris�aix�running�sleepingz disk-sleep�stoppedztracing-stop�zombie�deadz wake-kill�waking�idle�locked�waiting� suspended�parked�ESTABLISHED�SYN_SENT�SYN_RECV� FIN_WAIT1� FIN_WAIT2� TIME_WAIT�CLOSE� CLOSE_WAIT�LAST_ACK�LISTEN�CLOSING�NONE� � c @ s e Zd ZdZdZdZdS )� NicDuplexry rz r N)�__name__� __module__�__qualname__r# r$ r% � r r �A/opt/alt/python37/lib64/python3.7/site-packages/psutil/_common.pyr{ � s r{ ������c @ s e Zd ZdZdZdS )�BatteryTimer� r� N)r| r} r~ �POWER_TIME_UNKNOWN�POWER_TIME_UNLIMITEDr r r r� r� � s r� �replace�surrogateescape�total�used�free�percent�sin�sout� read_count�write_count� read_bytes�write_bytes� read_time� write_time�device� mountpoint�fstype�opts�maxfile�maxpath� bytes_sent� bytes_recv�packets_sent�packets_recv�errin�errout�dropin�dropout�name�terminal�host�started�pid�fd�family�type�laddr�raddr�status�address�netmask� broadcast�ptp�isup�duplex�speed�mtu�ctx_switches� interrupts�soft_interrupts�syscalls�scpufreq�current�min�max�shwtemp�label�high�critical�sbattery�secsleft� power_plugged�sfan�user�system� children_user�children_system�path�id� user_time�system_time�real� effective�saved�ioclass�value� voluntary�involuntary�addr�ip�port)�all�tcp�tcp4�udp�udp4�inet�inet4�inet6)�tcp6�udp6�unixc @ s* e Zd ZdZdZd dd�Zdd� ZeZdS ) �ErrorzQBase exception class. All other psutil exceptions inherit from this one. �psutil� c C s t �| |� || _d S )N)� Exception�__init__�msg)�selfr� r r r� r� s zError.__init__c C s d| j j| jf }|�� S )Nzpsutil.%s %s)� __class__r| r� �strip)r� �retr r r� �__repr__ s zError.__repr__N)r� )r| r} r~ �__doc__r� r� �__str__r r r r� r� s r� c @ s e Zd ZdZdZddd�ZdS )� NoSuchProcesszXException raised when a process with a certain PID doesn't or no longer exists. r� Nc C sX t �| |� || _|| _|| _|d krT|r@d| jt| j�f }n d| j }d| | _d S )Nz(pid=%s, name=%s)z(pid=%s)zprocess no longer exists )r� r� r� r� r� �repr)r� r� r� r� �detailsr r r� r� ' s zNoSuchProcess.__init__)NN)r| r} r~ r� r� r r r r� r� ! s r� c @ s e Zd ZdZdZddd�ZdS )� ZombieProcessa1 Exception 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. r� Nc C s~ t �| |� || _|| _|| _|| _|d krzd| g}|rN|�dt| j� � |rb|�d| j � dd�|� }d| | _d S )Nzpid=%szname=%szppid=%sz(%s)z, z'process still exists but it's a zombie ) r� r� r� �ppidr� r� �appendr� �join)r� r� r� r� r� �argsr� r r r� r� = s zZombieProcess.__init__)NNN)r| r} r~ r� r� r r r r� r� 4 s r� c @ s e Zd ZdZdZddd�ZdS )�AccessDeniedz@Exception raised when permission to perform an action is denied.r� Nc C sj t �| |� || _|| _|| _|d krf|d k rJ|d k rJd|t|�f | _n|d k r`d| j | _nd| _d S )Nz(pid=%s, name=%s)z(pid=%s)r� )r� r� r� r� r� r� )r� r� r� r� r r r� r� Q s zAccessDenied.__init__)NNN)r| r} r~ r� r� r r r r� r� M s r� c @ s e Zd ZdZdZddd�ZdS )�TimeoutExpiredzWRaised on Process.wait(timeout) if timeout expires and process is still alive. r� Nc C sn t �| d| � || _|| _|| _|d k rN|d k rN| jd|t|�f 7 _n|d k rj| jd| j 7 _d S )Nztimeout after %s secondsz (pid=%s, name=%s)z (pid=%s))r� r� �secondsr� r� r� r� )r� r� r� r� r r r� r� e s zTimeoutExpired.__init__)NN)r| r} r~ r� r� r r r r� r� _ s r� c C sD yt | �| d }W n tk r( dS X |dk r<t||�}|S dS )z5Calculate percentage usage of 'used' against 'total'.�d g N)�float�ZeroDivisionError�round)r� r� �round_r� r r r� rO u s c s2 t ���� �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() >>> c sH | t t|�� ��f}y� | S tk rB �| |� }� |<