????

Your IP : 18.191.130.191


Current Path : /lib/python3.6/site-packages/glances/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/glances/__pycache__/cpu_percent.cpython-36.opt-1.pyc

3

Eo�cK�@s>dZddlmZddlmZddlZGdd�de�Ze�ZdS)z;CPU percent stats shared between CPU and Quicklook plugins.�)�logger)�TimerNc@sLeZdZdZddd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�
CpuPercentzGet and store the CPU percent.�cCsTdddd�|_d|_g|_|j�||_td�|_td�|_|d|_td�|_	dS)N)�cpu_name�cpu_hz_current�cpu_hzr�)
�cpu_info�cpu_percent�percpu_percent�_CpuPercent__get_cpu_name�cached_timer_cpur�	timer_cpu�timer_percpu�cached_timer_cpu_info�timer_cpu_info)�selfr�r�!/usr/lib/python3.6/cpu_percent.py�__init__s


zCpuPercent.__init__cCsdS)z#Return the key of the per CPU list.�
cpu_numberr)rrrr�get_key)szCpuPercent.get_keyFcCs|r|j�S|j�SdS)zaUpdate and/or return the CPU using the psutil library.
        If percpu, return the percpu statsN)�_CpuPercent__get_percpu�_CpuPercent__get_cpu)r�percpurrr�get-szCpuPercent.getcCs�|jj�r�ttd�r�ytj�}Wn2tk
rR}ztjdj|��WYdd}~XnVXt|d�rl|j	|j
d<n
d|j
d<t|d�r�|j|j
d<n
d|j
d<|jj|j
d�|j
S)	z(Get additional information about the CPU�cpu_freqz!Can not grab CPU information ({})N�currentr�maxr)�duration)r�finished�hasattr�psutilr�	Exceptionr�debug�formatrr
r�resetr)rr�errr�get_info5s"



zCpuPercent.get_infoc	CsLy*tdd�j�djd�dj�|jd<Wnd|jd<YnX|jdS)Nz
/proc/cpuinfo�r��:�rZCPU)�open�	readlines�split�stripr
)rrrrZ__get_cpu_nameKs
*zCpuPercent.__get_cpu_namecCs.|jj�r(tjdd�|_|jj|jd�|jS)z6Update and/or return the CPU using the psutil library.g)�interval)r )rr!r#rr'r)rrrrZ	__get_cpuTs
zCpuPercent.__get_cpucCs|jj��rg|_x�ttjddd��D]�\}}|j�|td|jd�|j	|j
|jd�}t|d�rj|j|d<t|d�r~|j
|d<t|d	�r�|j|d	<t|d
�r�|j|d
<t|d�r�|j|d<t|d�r�|j|d<t|d
�r�|j|d
<|jj|�|jj|jd�q&W|jS)z?Update and/or return the per CPU list using the psutil library.gT)r2r�dr-)�keyrZtotal�user�system�idle�nice�iowait�irq�softirq�steal�guest�
guest_nice)r )rr!r�	enumerater#Zcpu_times_percentr�roundr7r5r6r"r8r9r:r;r<r=r>�appendr'r)rrZcputimesZcpurrrZ__get_percpu]s4














zCpuPercent.__get_percpuN)r)F)�__name__�
__module__�__qualname__�__doc__rrrr)r
rrrrrrrs

		r)	rEZglances.loggerrZ
glances.timerrr#�objectrrrrrr�<module>
s
p