File: //lib/python3.6/site-packages/glances/plugins/__pycache__/glances_wifi.cpython-36.pyc
3
Eo�c< � @ s� d Z ddlZddlmZmZ ddlmZ ddlmZ ddl Z yddl
mZ ddlm
Z
W n6 ek
r� Z zdZejd je�� W Y ddZ[X nX d
Zer�dZejd� G dd
� d
e�ZdS )zWifi plugin.� N)� nativestr�PY3)�logger)�
GlancesPlugin)�Cell)�InterfaceErrorTz0Missing Python Lib ({}), Wifi plugin is disabledFz@Wifi lib is not compliant with Python 3, Wifi plugin is disabledc s\ e Zd ZdZd� fdd� Zdd� Zejejdd� ��Z d d
� Z
� fdd�Zdd
d�Z� Z
S )�PluginzFGlances Wifi plugin.
Get stats of the current Wifi hotspots.
Nc s t t| �j||g d� d| _dS )zInit the plugin.)�args�configZstats_init_valueTN)�superr �__init__Z
display_curse)�selfr r
)� __class__� �"/usr/lib/python3.6/glances_wifi.pyr + s zPlugin.__init__c C s dS )zVReturn the key of the list.
:returns: string -- SSID is the dict key
�ssidr )r
r r r �get_key2 s zPlugin.get_keyc C s* | j � }tr|S | jdk�rytjdd�}W n tk
r@ |S X x�|D ]�}| j|�sXqHytj|�}W nb t k
r� } zt
jdj|�� W Y dd}~X qH t
k
r� } zt
jdj|�� W Y dd}~X qHX x@|D ]8}| j� |j|j|j|j|jr�|jndd�}|j|� q�W qHW n| jdk�r|| _| jS ) z�Update Wifi stats using the input method.
Stats is a list of dict (one dict per hotspot)
:returns: list -- Stats is a list of dict (hotspot)
ZlocalT)Zpernicz%WIFI plugin: Scan InterfaceError ({})Nz)WIFI plugin: Can not grab cell stats ({}))�keyr �signal�quality� encrypted�encryption_typeZsnmp)Zget_init_value�import_error_tagZinput_method�psutil�net_io_counters�UnicodeDecodeErrorZ
is_displayr �allr r �debug�format� Exceptionr r r r r r �append�stats)r
r! r ZnetZ
wifi_cells�eZ wifi_cellZhotspotr r r �update9 s8
"
z
Plugin.updatec C sv d}yP|| j d| jd�kr d}n2|| j d| jd�kr:d}n|| j d| jd�krRd}W n ttfk
rp d }Y nX |S )
z�Overwrite the default get_alert method.
Alert is on signal quality where lower is better...
:returns: string -- Signal alert
ZOKZcritical)Z stat_nameZCRITICAL�warningZWARNINGZcarefulZCAREFULZDEFAULT)Z get_limitZplugin_name� TypeError�KeyError)r
�value�retr r r � get_alertx s
zPlugin.get_alertc sv t t| �j� xb| jD ]X}| j|d �| j|| j� d d<