o
    Ìv›a#  ã                   @   s\   d Z ddlmZ ddlmZ ddddœdd	ddœd
dddœddddœgZG dd„ deƒZdS )zProcess count plugin.é    )Úglances_processes)ÚGlancesPluginÚtotalzTotal number of processesÚ )ÚnameÚdescriptionZy_unitÚrunningz!Total number of running processesÚsleepingz"Total number of sleeping processesÚthreadzTotal number of threadsc                       sT   e Zd ZdZdddddddd	œZd‡ fdd„	Zejejdd„ ƒƒZ	ddd„Z
‡  ZS )ÚPluginz7Glances process count plugin.

    stats is a list
    zdisk IOzCPU consumptionzmemory consumptionzprocess timez	user namezprocess nameÚNone)Zio_countersZcpu_percentZmemory_percentZ	cpu_timesZusernamer   NNc                    s    t t| ƒj||td d| _dS )zInit the plugin.)ÚargsÚconfigÚitems_history_listTN)Úsuperr   Ú__init__r   Zdisplay_curse)Úselfr   r   ©Ú	__class__© úF/usr/lib/python3/dist-packages/glances/plugins/glances_processcount.pyr   6   s
   þ
zPlugin.__init__c                 C   s<   |   ¡ }| jdkrt ¡  t ¡ }n| jdkr	 || _| jS )z.Update processes stats using the input method.ZlocalZsnmp)Zget_init_valueZinput_methodr   ÚupdateZgetcountÚstats)r   r   r   r   r   r   A   s   


zPlugin.updatec                 C   s  g }|j rd}| |  |¡¡ |S | js|S tjdurSd}| |  |d¡¡ d tj¡}tjdur9|d tj¡7 }| |  |d¡¡ d}| |  |¡¡ | |  ¡ ¡ d	}| |  |d¡¡ | jd
 }d | jd
 ¡}| |  |¡¡ d| jv rˆd | jd ¡}| |  |¡¡ d| jv r¤|| jd 8 }d | jd ¡}| |  |¡¡ d| jv rÀ|| jd 8 }d | jd ¡}| |  |¡¡ d |¡}| |  |¡¡ z| j	tj
 }W n tyá   tj
}Y nw tjrõd}| |  |¡¡ d |¡}nd |¡}| |  |¡¡ |S )z2Return the dict to display in the curse interface.z)PROCESSES DISABLED (press 'z' to display)NzProcesses filter:ZTITLEz {} zon column {} ZFILTERz('ENTER' to edit, 'E' to reset)ZTASKSr   z{:>4}r
   z
 ({} thr),r   z {} run,r	   z {} slp,z {} oth zsorted automaticallyz by {}zsorted by {})Zdisable_processÚappendZcurse_add_liner   r   Zprocess_filterÚformatZprocess_filter_keyZcurse_new_lineÚsort_for_humanZsort_keyÚKeyErrorZ	auto_sort)r   r   Z	max_widthÚretÚmsgÚotherZ
sort_humanr   r   r   Ú	msg_curseY   s^   







ÿ
zPlugin.msg_curse)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Z_check_decoratorZ_log_result_decoratorr   r    Ú__classcell__r   r   r   r   r   (   s    úr   N)r$   Zglances.processesr   Zglances.plugins.glances_pluginr   r   r   r   r   r   r   Ú<module>   s*   þþþþ÷