Your IP : 18.223.172.243


Current Path : /usr/lib64/python3.6/site-packages/psutil/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/psutil/__pycache__/_psosx.cpython-36.pyc

3

��JZ=C�@s�dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddl	mZ
dd	l	mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZddl
mZddl
mZddlmZddlmZddlmZgZejd�ZejZe
j e
j!e
j"e
j#e
j$e
j%e
j&e
j'e
j(e
j)e
j*e
j+e
j,e
j-e
j.e
j/e
j0e
j1e
j2e
j3e
j4e
j5e
j6e
j7iZ8e
j9e
j:e
j;e
j<e
j=e
j>e
j?e
j@e
jAe
jBiZCeDdddddddddddd�ZEeDddddddddd �ZFed!d"d#d$d%g�ZGed&d'd(d)d*d+d,d-d.g�ZHed/d0d1d2d3g�ZIed4eIjJda�ZKed6d7�ZLed8d9d:jMeLjJ��ZNd;d<�ZOd=d>�ZPd?d@�ZQdAdB�ZRdCdD�ZSdEdF�ZTdGdH�ZUdIdJ�ZVejWZWe
jXZXdbdLdM�ZYdNdO�ZZe
j[Z[ej\Z\dcdQdR�Z]dSdT�Z^dUdV�Z_dWdX�Z`dYdZ�ZaejbZbd[d\�Zcejdd]d^��ZeGd_d`�d`ef�ZgdS)dzOSX platform implementation.�N)�AF_INET)�
namedtuple�)�_common)�_psposix)�_psutil_osx)�
_psutil_posix)�AF_INET6)�	conn_tmap)�
isfile_strict)�memoize_when_activated)�parse_environ_block)�sockfam_to_enum)�socktype_to_enum)�
usage_percent)�AccessDenied)�
NoSuchProcess)�
ZombieProcess�SC_PAGE_SIZE��������	�
)�ppid�ruid�euid�suid�rgid�egid�sgid�ttynr�ctime�status�name)�cpuutime�cpustime�rss�vms�pfaults�pageins�
numthreads�volctxsw�	scputimes�user�nice�system�idle�svmem�totalZ	available�percent�used�free�active�inactive�wired�pmemr+r,r-r.�pfullmem�uss�
pmmap_groupedz7path rss private swapped dirtied ref_count shadow_depth�	pmmap_extzaddr perms � c	CsNtj�\}}}}}||}|||}t|||dd�}t||||||||�S)z&System virtual memory as a namedtuple.r)�_round)�cextZvirtual_memrr6)r7r;r<r=r:Zavailr9r8�rF�/usr/lib64/python3.6/_psosx.py�virtual_memoryxsrHcCs4tj�\}}}}}t||dd�}tj||||||�S)z=Swap system memory as a (total, used, free, sin, sout) tuple.r)rD)rEZswap_memrrZsswap)r7r9r:ZsinZsoutr8rFrFrG�swap_memory�srIcCstj�\}}}}t||||�S)z(Return system CPU times as a namedtuple.)rE�	cpu_timesr1)r2r3r4r5rFrFrGrJ�srJcCs>g}x4tj�D](}|\}}}}t||||�}|j|�qW|S)z(Return system CPU times as a named tuple)rE�
per_cpu_timesr1�append)�retZcpu_tr2r3r4r5�itemrFrFrGrK�srKcCstj�S)z0Return the number of logical CPUs in the system.)rE�cpu_count_logicalrFrFrFrGrO�srOcCstj�S)z1Return the number of physical CPUs in the system.)rEZcpu_count_physrFrFrFrG�cpu_count_physical�srPcCs"tj�\}}}}}tj||||�S)N)rE�	cpu_statsrZ	scpustats)Zctx_switchesZ
interruptsZsoft_interruptsZsyscallsZtrapsrFrFrGrQ�srQcCstj�\}}}tj|||�gS)z�Return CPU frequency.
    On OSX per-cpu frequency is not supported.
    Also, the returned frequency never changes, see:
    https://arstechnica.com/civis/viewtopic.php?f=19&t=465002
    )rE�cpu_freqrZscpufreq)ZcurrZmin_Zmax_rFrFrGrR�srRFc	Csrg}tj�}x`|D]X}|\}}}}|dkr.d}|sPtjj|�stjj|�rPqtj||||�}|j|�qW|S)z8Return mounted disk partitions as a list of namedtuples.Znone�)	rE�disk_partitions�os�path�isabs�existsrZ	sdiskpartrL)	�all�retlistZ
partitions�	partitionZdeviceZ
mountpointZfstypeZopts�ntuplerFrFrGrT�s
rTcCsbytj�\}}}Wntk
r&dSX|dk}|r<tj}n|dkrLtj}n|d}tj|||�S)z Return battery information.
    Nr�<���)rE�sensors_battery�NotImplementedErrorrZPOWER_TIME_UNLIMITEDZPOWER_TIME_UNKNOWNZsbattery)r8ZminsleftZ
power_pluggedZsecsleftrFrFrGr_�sr_�inetc
Csrg}xht�D]^}yt|�j|�}Wntk
r8wYqX|rx*|D]"}t|�|g}|jtj|��qDWqW|S)z System-wide network connections.)�pids�Process�connectionsr�listrLrZsconn)�kindrM�pidZcons�crFrFrG�net_connections�s
ricCsjt�j�}i}xV|D]N}tj|�}tj|�}tj|�\}}ttd�rNtj|�}tj	||||�||<qW|S)z)Get NIC stats (isup, duplex, speed, mtu).�	NicDuplex)
�net_io_counters�keys�
cext_posixZ
net_if_mtuZnet_if_flagsZnet_if_duplex_speed�hasattrrrjZ	snicstats)�namesrMr(ZmtuZisupZduplexZspeedrFrFrG�net_if_statss





rpcCstj�S)z:The system boot time expressed in seconds since the epoch.)rE�	boot_timerFrFrFrGrqsrqc	Cs`g}tj�}xN|D]F}|\}}}}}|dkr.q|s4qtj||p@d|pFd||�}|j|�qW|S)z:Return currently connected users as a list of namedtuples.�~N)rE�usersrZsuserrL)	rZ�rawlistrNr2ZttyZhostnameZtstamprg�ntrFrFrGrss
rscCs`tj�}d|kr\ytd�j�|jd�Wn0tk
r>Yntk
rZ|jd�YnX|S)Nr)rErbrc�create_timerLrr)ZlsrFrFrGrb0srbcstj���fdd��}|S)z`Decorator which translates bare OSError exceptions into
    NoSuchProcess and AccessDenied.
    csty�|f|�|�Stk
rn}zB|jtjkr<t|j|j��|jtjtjfkr\t|j|j���WYdd}~XnXdS)N)	�OSError�errno�ESRCHrrg�_nameZEPERMZEACCESr)�self�args�kwargs�err)�funrFrG�wrapperGsz wrap_exceptions.<locals>.wrapper)�	functools�wraps)rr�rF)rrG�wrap_exceptionsCs
r�ccs�y
dVWn�ttfk
r�}zrt|t�s6|jtjkr�y|j�}Wntk
rZ|�Yq�X|tjkrzt	|j
|j|j��q�t
|j
|j��n�WYdd}~XnXdS)z�There are some poor C APIs which incorrectly raise ESRCH when
    the process is still alive or it's a zombie, or even RuntimeError
    (those who don't set errno). This is here in order to solve:
    https://github.com/giampaolo/psutil/issues/1044
    N)rw�RuntimeError�
isinstancerxryr'rr�
STATUS_ZOMBIErrgrz�_ppidr)�procr~r'rFrFrG�catch_zombieTs


r�c@sneZdZdZdddgZdd�Zedd��Zed	d
��Zdd�Z	d
d�Z
edd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zed#d$��Zed%d&��Zed'd(��Zed)d*��Zed+d,��Zed-d.��ZedAd0d1��Zed2d3��ZedBd5d6��Zed7d8��Zed9d:��Z ed;d<��Z!ed=d>��Z"ed?d@��Z#d4S)Crcz1Wrapper class around underlying C implementation.rgrzr�cCs||_d|_d|_dS)N)rgrzr�)r{rgrFrFrG�__init__sszProcess.__init__cCs$tj|j�}t|�tt�ks t�|S)N)rEZproc_kinfo_oneshotrg�len�kinfo_proc_map�AssertionError)r{rMrFrFrG�_get_kinfo_procxszProcess._get_kinfo_procc
Cs8t|��tj|j�}WdQRXt|�tt�ks4t�|S)N)r�rEZproc_pidtaskinfo_oneshotrgr��pidtaskinfo_mapr�)r{rMrFrFrG�_get_pidtaskinfos
zProcess._get_pidtaskinfocCs|jj�|jj�dS)N)r�Zcache_activater�)r{rFrFrG�
oneshot_enter�s
zProcess.oneshot_entercCs|jj�|jj�dS)N)r�Zcache_deactivater�)r{rFrFrG�oneshot_exit�s
zProcess.oneshot_exitcCs(|j�td}|dk	r|Stj|j�S)Nr()r�r�rEZ	proc_namerg)r{r(rFrFrGr(�szProcess.namec	Cs t|��tj|j�SQRXdS)N)r�rEZproc_exerg)r{rFrFrG�exe�s
zProcess.exec	Cs t|��tj|j�SQRXdS)N)r�rEZproc_cmdlinerg)r{rFrFrG�cmdline�s
zProcess.cmdlinec
Cs$t|��ttj|j��SQRXdS)N)r�r
rEZproc_environrg)r{rFrFrG�environ�s
zProcess.environcCs|j�td|_|jS)Nr)r�r�r�)r{rFrFrGr�szProcess.ppidc	Cs t|��tj|j�SQRXdS)N)r�rEZproc_cwdrg)r{rFrFrG�cwd�s
zProcess.cwdcCs.|j�}tj|td|td|td�S)Nrr r!)r�r�puidsr�)r{�rawtuplerFrFrG�uids�s


zProcess.uidscCs.|j�}tj|td|td|td�S)Nr"r#r$)r�rr�r�)r{r�rFrFrG�gids�s


zProcess.gidscCs:|j�td}tj�}y||Stk
r4dSXdS)Nr%)r�r�rZget_terminal_map�KeyError)r{Ztty_nrZtmaprFrFrG�terminal�szProcess.terminalcCs6|j�}t|td|td|td|td�S)Nr+r,r-r.)r�r>r�)r{r�rFrFrG�memory_info�s


zProcess.memory_infocCs"|j�}tj|j�}t||f�S)N)r�rEZproc_memory_ussrgr?)r{Z	basic_memr@rFrFrG�memory_full_info�szProcess.memory_full_infocCs(|j�}tj|td|tddd�S)Nr)r*g)r�rZ	pcputimesr�)r{r�rFrFrGrJ�s


zProcess.cpu_timescCs|j�tdS)Nr&)r�r�)r{rFrFrGrv�szProcess.create_timecCs|j�td}tj|d�S)Nr0r)r�r�rZpctxsw)r{ZvolrFrFrG�num_ctx_switches�szProcess.num_ctx_switchescCs|j�tdS)Nr/)r�r�)r{rFrFrG�num_threads�szProcess.num_threadscCsf|jdkrgSg}t|��tj|j�}WdQRXx.|D]&\}}t|�r8tj||�}|j|�q8W|S)Nr)rgr�rEZproc_open_filesrrZ	popenfilerL)r{�filesrtrV�fdr\rFrFrG�
open_files�s

zProcess.open_filesracCs�|tkr(td|djdd�tD��f��t|\}}t|��tj|j||�}WdQRXg}xz|D]r}|\}}}	}
}}t|}t|�}t	|	�}	|t
tfkr�|
r�tj
|
�}
|r�tj
|�}tj|||	|
||�}
|j|
�qbW|S)Nz+invalid %r kind argument; choose between %sz, cSsg|]}t|��qSrF)�repr)�.0�xrFrFrG�
<listcomp>sz'Process.connections.<locals>.<listcomp>)r
�
ValueError�joinr�rEZproc_connectionsrg�TCP_STATUSESrrrr	rZaddrZpconnrL)r{rfZfamilies�typesrtrMrNr�Zfam�typeZladdrZraddrr'rurFrFrGrd�s(



zProcess.connectionsc	Cs.|jdkrdSt|��tj|j�SQRXdS)Nr)rgr�rEZproc_num_fds)r{rFrFrG�num_fdss

zProcess.num_fdsNcCstj|j||j�S)N)rZwait_pidrgrz)r{ZtimeoutrFrFrG�waitszProcess.waitc	Cs t|��tj|j�SQRXdS)N)r�rm�getpriorityrg)r{rFrFrG�nice_gets
zProcess.nice_getc
Cs"t|��tj|j|�SQRXdS)N)r�rm�setpriorityrg)r{�valuerFrFrG�nice_set#s
zProcess.nice_setcCs|j�td}tj|d�S)Nr'�?)r�r��
PROC_STATUSES�get)r{�coderFrFrGr'(szProcess.statuscCsTt|��tj|j�}WdQRXg}x*|D]"\}}}tj|||�}|j|�q*W|S)N)r�rEZproc_threadsrgrZpthreadrL)r{rtrZZ	thread_id�utimeZstimer\rFrFrG�threads.s
zProcess.threadsc	Cs t|��tj|j�SQRXdS)N)r�rEZproc_memory_mapsrg)r{rFrFrG�memory_maps8s
zProcess.memory_maps)ra)N)$�__name__�
__module__�__qualname__�__doc__�	__slots__r�rr�r�r�r�r�r(r�r�r�rr�r�r�r�r�r�rJrvr�r�r�rdr�r�r�r�r'r�r�rFrFrFrGrcnsB
	
	

rc)r@)F)ra)hr��
contextlibrxr�rUZsocketr�collectionsrrSrrrrErrmr	r
rrr
rrr�_exceptionsrrrZ__extra__all__�sysconfZPAGESIZEZAF_LINKZTCPS_ESTABLISHEDZCONN_ESTABLISHEDZ
TCPS_SYN_SENTZ
CONN_SYN_SENTZTCPS_SYN_RECEIVEDZ
CONN_SYN_RECVZTCPS_FIN_WAIT_1ZCONN_FIN_WAIT1ZTCPS_FIN_WAIT_2ZCONN_FIN_WAIT2ZTCPS_TIME_WAITZCONN_TIME_WAITZTCPS_CLOSEDZ
CONN_CLOSEZTCPS_CLOSE_WAITZCONN_CLOSE_WAITZ
TCPS_LAST_ACKZ
CONN_LAST_ACKZTCPS_LISTENZCONN_LISTENZTCPS_CLOSINGZCONN_CLOSINGZPSUTIL_CONN_NONEZ	CONN_NONEr�ZSIDLZSTATUS_IDLEZSRUNZSTATUS_RUNNINGZSSLEEPZSTATUS_SLEEPINGZSSTOPZSTATUS_STOPPEDZSZOMBr�r��dictr�r�r1r6r>�_fieldsr?rAr�rBrHrIrJrKrOrPrQrRZ
disk_usageZdisk_io_countersrTr_rkZnet_if_addrsrirprqrsrbZ
pid_existsr��contextmanagerr��objectrcrFrFrFrG�<module>s�







?>