U �=�_{H � @ s� d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m Z ddl mZ ddl mZ ddl mZ dd l mZ dd l mZ ddl mZ ddl mZ dd l mZ ddl mZ ddl mZ ddl mZ ddl mZ ddl mZ ddlmZ ddlmZ ddlmZ ddlmZ dgZe e d�Z!e e d�Z"e e d�Z#e�$� Z%ej&Z&e j'e j(e j)e j*e j+e j,e j-e j,e j.e j/iZ0e j1e j2e j3e j4e j5e j6e j7e j8e j9e j:e j;e j<e j=e j>e j?e j@e jAe jBe jCe jDe jEe jFe jGe jHiZIeJdddddddd d!�ZKed"d#d$g�ZLeLZMed%d&d'd(d)g�ZNed*d+d,d-d.d/g�ZOd0d1� ZPd2d3� ZQd4d5� ZRd6d7� ZSd8d9� ZTd:d;� ZUd<d=� ZVe jWZWejXZXdRd?d@�ZYejZZZe"�r�e j[Z[dSdBdC�Z\dDdE� Z]dFdG� Z^dHdI� Z_dJdK� Z`dLdM� ZadNdO� ZbG dPdQ� dQec�ZddS )TzAIX platform implementation.� N)� namedtuple� )�_common)�_psposix)�_psutil_aix)� _psutil_posix)�AccessDenied)�conn_to_ntuple)�get_procfs_path)�memoize_when_activated)�NIC_DUPLEX_FULL)�NIC_DUPLEX_HALF)�NIC_DUPLEX_UNKNOWN)� NoSuchProcess)� usage_percent)� ZombieProcess)�FileNotFoundError)�PermissionError)�ProcessLookupError)�PY3ZPROCFS_PATH�proc_threads�net_io_counters�proc_io_counters� � � � � � )�ppid�rss�vms�create_time�nice�num_threads�status�ttynr�pmemr r! � scputimes�user�systemZidleZiowait�svmem�totalZ available�percent�used�freec C s4 t �� \} }}}}t| | | dd�}t| ||||�S )Nr �Zround_)�cextZvirtual_memr r+ )r, Zavailr/ ZpinnedZinuser- � r2 �@/opt/alt/python38/lib64/python3.8/site-packages/psutil/_psaix.py�virtual_memoryj s r4 c C s: t �� \} }}}| | }t|| dd�}t�| |||||�S )z=Swap system memory as a (total, used, free, sin, sout) tuple.r r0 )r1 Zswap_memr r Zsswap)r, r/ ZsinZsoutr. r- r2 r2 r3 �swap_memoryp s r5 c C s t �� } tdd� t| � D �� S )z-Return system-wide CPU times as a named tuplec S s g | ]}t |��qS r2 )�sum��.0�xr2 r2 r3 � <listcomp>� s zcpu_times.<locals>.<listcomp>)r1 � per_cpu_timesr( �zip��retr2 r2 r3 � cpu_times} s r? c C s t �� } dd� | D �S )z5Return system per-CPU times as a list of named tuplesc S s g | ]}t |� �qS r2 )r( r7 r2 r2 r3 r: � s z!per_cpu_times.<locals>.<listcomp>)r1 r; r= r2 r2 r3 r; � s r; c C s( zt �d�W S tk r" Y dS X dS )z0Return the number of logical CPUs in the system.�SC_NPROCESSORS_ONLNN)�os�sysconf� ValueErrorr2 r2 r2 r3 �cpu_count_logical� s rD c C sr d} t j| dt jt jd�}|�� \}}tr@dd� ||fD �\}}|jdkrZtd| |f ��|�� �� }t |�ppd S )Nzlsdev -Cc processorT)�shell�stdout�stderrc S s g | ]}|� tjj��qS r2 ��decode�sysrF �encodingr7 r2 r2 r3 r: � s �z&cpu_count_physical.<locals>.<listcomp>r z%r command error %s) � subprocess�Popen�PIPE�communicater � returncode�RuntimeError�strip� splitlines�len)�cmd�prF rG Z processorsr2 r2 r3 �cpu_count_physical� s �� rW c C s t �� \} }}}t�| |||�S )z*Return various CPU stats as a named tuple.)r1 � cpu_statsr Z scpustats)Zctx_switchesZ interruptsZsoft_interruptsZsyscallsr2 r2 r3 rX � s �rX Fc C sh g }t �� }|D ]R}|\}}}}|dkr,d}| s<t|�js<qd }} t�|||||| �} |�| � q|S )zReturn system disk partitions.Znone� N)r1 �disk_partitions� disk_usager, r Z sdiskpart�append)�all�retlistZ partitions� partitionZdeviceZ mountpointZfstypeZoptsZmaxfileZmaxpath�ntupler2 r2 r3 rZ � s �rZ ���c C s� t j}| |kr.td| d�dd� |D ��f ��t j| \}}t�|�}g }|D ]X}|\}} } }}} }| |krnqN| |krxqNt|| | ||| t|dkr�|ndd�}|�|� qN|S )z�Return socket connections. If pid == -1 return system-wide connections (as opposed to connections opened by one process only). z+invalid %r kind argument; choose between %sz, c S s g | ]}t |��qS r2 )�reprr7 r2 r2 r3 r: � s z#net_connections.<locals>.<listcomp>ra N��pid) r Z conn_tmaprC �joinr1 �net_connectionsr �TCP_STATUSESr\ )�kind�_pidZcmapZfamilies�types�rawlistr>