????

Your IP : 3.23.61.5


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

3

Eo�c�@spdZddlmZddlmZddlmZyddlZWn"ek
rVej	d�dZ
YnXdZ
Gd	d
�d
e�ZdS)zManage on alert actions.�)�logger)�Timer)�secure_popenNz5Chevron library not found (action scripts won't work)FTc@s4eZdZdZddd�Zdd�Zdd�Zdd	d
�ZdS)
�GlancesActionsz0This class manage action if an alert is reached.NcCs0i|_t|d�r"t|jd�|_n
td�|_dS)zInit GlancesActions class.�time��N)�status�hasattrrr�start_timer)�self�args�r�/usr/lib/python3.6/actions.py�__init__s
zGlancesActions.__init__cCs$y
|j|Stk
rdSXdS)zGet the stat_name criticality.N)r	�KeyError)r�	stat_namerrr�get,s
zGlancesActions.getcCs||j|<dS)z!Set the stat_name to criticality.N)r	)rr�criticalityrrr�set3szGlancesActions.setc
Cs�|j|�|kr|s |jj�r$dStjdj|r4dnd||||��x�|D]�}tr`tj||�}n|}tj	dj|||��yt
|�}Wn6tk
r�}	ztjdj|||	��WYdd}	~	XqJXtjdj|||��qJW|j
||�d	S)
a�Run the commands (in background).

        :param stat_name: plugin_name (+ header)
        :param criticality: criticality of the trigger
        :param commands: a list of command line with optional {{mustache}}
        :param repeat: If True, then repeat the action
        :param  mustache_dict: Plugin stats (can be use within {{mustache}})

        :return: True if the commands have been ran.
        Fz&{} action {} for {} ({}) with stats {}ZRepeatZRunz Action triggered for {} ({}): {}zAction error for {} ({}): {}NzAction result for {} ({}): {}T)rrZfinishedr�debug�format�chevron_tag�chevronZrender�infor�OSError�errorr)
rrrZcommands�repeatZ
mustache_dict�cmdZcmd_full�ret�errr�run7s" 
&zGlancesActions.run)N)N)�__name__�
__module__�__qualname__�__doc__rrrr!rrrrrs

r)
r%Zglances.loggerrZ
glances.timerrZglances.securerr�ImportErrorrr�objectrrrrr�<module>
s