관리-도구
편집 파일: __init__.cpython-37.pyc
B �=�_�� � E @ s� d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZ ddlmZ ddlmZ ddlZddlmZ ddlmZ dd lmZ dd lm Z ddlm!Z! ddlm"Z" dd lm#Z# ddl$m%Z% ddl$m&Z& ddl$m'Z' ddl(m)Z) ddl(m*Z* ddl(m+Z+ ddl(m,Z, ddl(m-Z- ddl(m.Z. ddl(m/Z/ ddl(m0Z0 e+�r�ddl1Z1nddl2Z1yddl1m3Z3 W n< e4k �r( e�5� � e�6d� ddl3Z3W dQ R X Y nX ej7dk�r@ddl8Z8ndZ8ddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`gEZ9daej:kZ;de j<kZ=dbe j<k�p�dce j<kZ>e=�pe>Z?ej@ddkZAdeZBdfZCdgZDdhZEe?�rFeBdi9 ZBeEdi9 ZEeCdi9 ZCeDdi9 ZDe jFdjk�r`dke �G� ZHndle �G� ZHe.dm�ZIe+�r�dn�Jdodp�ZKndqZKe�L� �M� drkZNe jO�Pe jO�Qe jO�ReS�dsds��ZTe jO�QeTdt�ZUe jO�Pe jO�ReS��ZVe!�o�e" ZWeXejYdu�ZZeXedv�Z[eXedw�Z\eXejYdx�Z]eXejYdy�Z^eXejYdz�Z_eXed{�Z`eXejYd|�ZaeXejYd}�ZbeXejYd~�ZceXed�Zdyed�oxeee�f� �ZgW n ehk �r� d�ZgY nX eXed��ZieXed��ZjeXejYd��Zke �s�e�o�e �l� dkZmd�d�� Znen� Zoepe jqd��Zre�serjt� d�d�� eue�D �Zvewed�ex� �Zyez� Z{ez� Z|G d�d�� d�ej}�Z~d�d�� Zed�d�d<��Z�ed�d>� �Z�d�d=� Z�ed�d9� �Z�ed�d�� �Z�ej�eEfd�d:�Z�d�d�d;�Z�d�dQ� Z�d�dP� Z�G d�d�� d�ex�Z�e�ej�deEd�d��d�dS� �Z�e�e*e�fdeEd�d��d�d�dT��Z�e�e�deEd�d��d�dR� �Z�d�dK� Z�d�d�� Z�ej�d�dJ� �Z�d�d�dL�Z�d�d�dO�Z�G d�d�� d�e1j��Z�e�e1_�G d�dD� dDe��Z�e1��e;d��G d�dC� dCe���Z�d�dG� Z�d�d�� Z�G d�dE� dE�Z�G d�dF� dF�Z�d�d�� Z�eBfd�dB�Z�d�d�d@�Z�d�d�dA�Z�d�d�dV�Z�eedfd�dW�Z�ejfd�dX�Z�d�d�dY�Z�d�dZ� Z�ej�d�d[� �Z�d�dU� Z�d�d�� Z�d�d\� Z�d�d]� Z�d�d^� Z�d�d`� Z�e!�rZej�d�d�d_��Z�nej�d�d�d_��Z�ejsd�dȄ �Z�e!�r�e�ej�d�dʄ � dS )�z Test utilities. � )�print_functionN)�AF_INET)�AF_INET6)�SOCK_STREAM)�AIX)�FREEBSD)�LINUX)�MACOS)�POSIX)�SUNOS)�WINDOWS)�bytes2human)�print_color)� supports_ipv6)�FileExistsError)�FileNotFoundError)�PY3)�range)�super)�u)�unicode)�which)�mock�ignore)� � �APPVEYOR�DEVNULL�GLOBAL_TIMEOUT�TOLERANCE_SYS_MEM� NO_RETRIES�PYPY� PYTHON_EXE�ROOT_DIR�SCRIPTS_DIR� TESTFN_PREFIX�UNICODE_SUFFIX�INVALID_UNICODE_SUFFIX� CI_TESTING�VALID_PROC_STATUSES�TOLERANCE_DISK_USAGE�IS_64BIT�HAS_CPU_AFFINITY�HAS_CPU_FREQ�HAS_ENVIRON�HAS_PROC_IO_COUNTERS� HAS_IONICE�HAS_MEMORY_MAPS�HAS_PROC_CPU_NUM� HAS_RLIMIT�HAS_SENSORS_BATTERY�HAS_BATTERY�HAS_SENSORS_FANS�HAS_SENSORS_TEMPERATURESZHAS_MEMORY_FULL_INFO�pyrun� terminate� reap_children�spawn_testproc�spawn_zombie�spawn_children_pairZThreadTaskunittest�skip_on_access_denied�skip_on_not_implemented�retry_on_failure�TestMemoryLeak�PsutilTestCase�process_namespace�system_namespace� print_sysinfoZinstall_pipZinstall_test_deps�chdir�safe_rmpath� create_exeZdecode_pathZencode_path� get_testfn� get_winver�kernel_version� call_until�wait_for_pid� wait_for_file�check_net_address� get_free_port�bind_socket�bind_unix_socket�tcp_socketpair�unix_socketpair�create_sockets� reload_module�import_module_by_path�warn�copyload_shared_lib� is_namedtuple�__pypy__�GITHUB_ACTIONSZCIBUILDWHEELl � i P i � � r �javaz$psutil-%s-z@psutil-%s-u -ƒőős f���utf8�surrogateescapeu fÀ)�asciizus-asciiz..�scripts�cpu_affinity�cpu_freq� getloadavg�environ�ionice�memory_maps�net_io_counters�cpu_num�io_counters�rlimit�sensors_batteryF�sensors_fans�sensors_temperatures�threadsc C s� dd� } t r@tr$trtd�S td�S tr6tj�tj �S td�S n�t r�| tj �p�| tj�tj ��p�| tdtjd d� ��p�| t� � �� �}|s�td��|S tj�tj �}tj�|�s�t|��|S d S ) Nc S s: yt j| dgt jt jd� W n tk r0 d S X | S d S )Nz-V)�stdout�stderr)� subprocess� check_call�PIPE� Exception)�exe� ry �H/opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/__init__.py�attempt� s z_get_py_exe.<locals>.attemptZpypy3�pypy�pythonzpython%s.%s� z"can't find python exe real abspath)r\ r! r r r �os�path�realpath�sys� executabler �version_info�psutil�Processrx � ValueError�exists�AssertionError)r{ rx ry ry rz �_get_py_exe� s$ r� zr+c C s g | ]}|� d �rtt|��qS )ZSTATUS_)� startswith�getattrr� )�.0�xry ry rz � <listcomp>� s r� �AF_UNIXc sP e Zd ZdZ� fdd�Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z � ZS )� ThreadTaskz6A thread task which does nothing expect staying alive.c s$ t � �� d| _d| _t�� | _d S )NFg����MbP?)r �__init__�_running� _interval� threading�Event�_flag)�self)� __class__ry rz r� � s zThreadTask.__init__c C s | j j}d|| jt| �f S )Nz<%s running=%s at %#x>)r� �__name__r� �id)r� �namery ry rz �__repr__� s zThreadTask.__repr__c C s | � � | S )N)�start)r� ry ry rz � __enter__ s zThreadTask.__enter__c O s | � � d S )N)�stop)r� �args�kwargsry ry rz �__exit__ s zThreadTask.__exit__c C s( | j rtd��tj�| � | j�� dS )zStart thread and keep it running until an explicit stop() request. Polls for shutdown every 'timeout' seconds. zalready startedN)r� r� r� �Threadr� r� �wait)r� ry ry rz r� s zThreadTask.startc C s, d| _ | j�� x| j r&t�| j� qW d S )NT)r� r� �set�time�sleepr� )r� ry ry rz �run s zThreadTask.runc C s | j std��d| _ | �� dS )z8Stop thread execution and and waits until it is stopped.zalready stoppedFN)r� r� �join)r� ry ry rz r� s zThreadTask.stop)r� � __module__�__qualname__�__doc__r� r� r� r� r� r� r� � __classcell__ry ry )r� rz r� � s r� c s t �� �� fdd��}|S )Nc s, y � | |�S t k r& t� � Y nX d S )N)rw r: )r� r� )�funry rz �wrapper% s z&_reap_children_on_err.<locals>.wrapper)� functools�wraps)r� r� ry )r� rz �_reap_children_on_err$ s r� c K s� |� dt� |� dt� |� dt�� � |� dtj� trJd}|� d|� | dkr�t� }zDt|� d| }td |g} t j | f|�}t�|� t |d d d� W dt|� X n"t j | f|�}t�|� t|j� |S )a} Creates a python subprocess which does nothing for 60 secs and return it as a subprocess.Popen instance. If "cmd" is specified that is used instead of python. By default stdin and stdout are redirected to /dev/null. It also attemps to make sure the process is in a reasonably initialized state. The process is registered for cleanup on reap_children(). �stdinrr �cwd�envi � creationflagsNz:from time import sleep;open(r'%s', 'w').close();sleep(60);z-cT)�delete�empty)� setdefaultr r �getcwdrg r rI rG r"