Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/plugins.cpython-36.pyc

3

�uGh�	�@sFddlZddlZddlZejdkr,ddlZnddlZGdd�d�ZdS)�N�c@sJeZdZdZdZgfdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�
BasePluginz$
    Abstract class for plugins
    �cCst|t�r||_ntd��dS)Nz#Type of agent_cache have to be list)�
isinstance�list�agent_cache�	TypeError)�selfr�r
�A/root/tmp/pip-build-gzoz1_uw/agent360/agent360/plugins/plugins.py�__init__s
zBasePlugin.__init__NcCsdS)z7
        Virtual method for running the plugin
        Nr
)r	�configr
r
r�runszBasePlugin.runcCs\d}ttj�dkrBtjdkr(tjt�}n
tjt�}|jtjd�t	j
|j|�tjj
�dS)zL
        Execution wrapper for the plugin
        argv[1]: ini_file
        N�r)r)�len�sys�argv�version_info�configparser�RawConfigParser�defaults�ConfigParser�read�pickle�dumpr�stdout�buffer)r	r
r
r
r�execute!s

zBasePlugin.executecCs$y
|jdStk
riSXdS)zE
        Return agent cached value for this specific plugin.
        rN)r�	Exception)r	r
r
r�get_agent_cache/s
zBasePlugin.get_agent_cachecCs4y||jd<Wn tk
r.|jj|�YnXdS)a�
        Set agent cache value previously passed to this plugin instance.
        To enable caching existing agent_cache list have to be passed
        to Plugin on initialization.
        Minimally it should be list().
        Agent will be able to see only changes in zero element of agent_cache, so
        do not manually override self.agent_cache, othervice cache will not be saved!

        If self.agent_cache is not a list appropriate exception will be raised.
        rN)r�
IndexError�append)r	�cacher
r
r�set_agent_cache8szBasePlugin.set_agent_cachecCs`yB|||kr,|||tj�|d}n|tj�|d}Wntk
rZd}YnX|S)N�tsr)�timer)r	�key�valZ
prev_cache�valuer
r
r�absolute_to_per_secondHs

z!BasePlugin.absolute_to_per_second)N)
�__name__�
__module__�__qualname__�__doc__rrrrr#r)r
r
r
rrs	
	r)r)rr%rrrrrr
r
r
r�<module>s



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists