HEX
Server: LiteSpeed
System: Linux baran.dnsprotection.me 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: ddir12 (3618)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/glances/plugins/__pycache__/glances_wifi.cpython-36.opt-1.pyc
3

Eo�c<�@s�dZddlZddlmZmZddlmZddlmZddl	Z	yddl
mZddlm
Z
Wn6ek
r�ZzdZejd	je��WYddZ[XnXd
Zer�dZejd�Gdd
�d
e�ZdS)zWifi 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 disabledcs\eZdZdZd�fdd�	Zdd�Zejejdd���Z	d	d
�Z
�fdd�Zdd
d�Z�Z
S)�PluginzFGlances Wifi plugin.

    Get stats of the current Wifi hotspots.
    Ncs tt|�j||gd�d|_dS)zInit the plugin.)�args�configZstats_init_valueTN)�superr�__init__Z
display_curse)�selfr	r
)�	__class__��"/usr/lib/python3.6/glances_wifi.pyr+szPlugin.__init__cCsdS)zVReturn the key of the list.

        :returns: string -- SSID is the dict key
        �ssidr)r
rrr�get_key2szPlugin.get_keycCs*|j�}tr|S|jdk�rytjdd�}Wntk
r@|SXx�|D]�}|j|�sXqHytj|�}Wnbt	k
r�}zt
jdj|��WYdd}~XqHt
k
r�}zt
jdj|��WYdd}~XqHXx@|D]8}|j�|j|j|j|j|jr�|jndd�}|j|�q�WqHWn|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_tagZinput_method�psutil�net_io_counters�UnicodeDecodeErrorZ
is_displayr�allrr�debug�format�	Exceptionrrrrrr�append�stats)r
r!rZnetZ
wifi_cells�eZ	wifi_cellZhotspotrrr�update9s8


 "
z
Plugin.updatecCsvd}yP||jd|jd�kr d}n2||jd|jd�kr:d}n||jd|jd�krRd}Wnttfk
rpd	}YnX|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�retrrr�	get_alertxs
zPlugin.get_alertcsvtt|�j�xb|jD]X}|j|d�|j||j�dd<|j||j�dd|j||j�dd<qWdS)zUpdate stats views.r�
decorationrN)rr�update_viewsr!r)Zviewsr)r
�i)rrrr+�s
$zPlugin.update_viewsc	CsVg}|jsts|j�r|S|d}djd|d�}|j|j|d��djd�}|j|j|��x�t|jtj|j	��d�D]�}|d	d
ksx|d	dksx|ddkr�qx|j|j
��|d	}|d
r�|dj|d�7}t|�|kr�d||dd�}djt|�|d�}|j|j|��dj|d|d�}|j|j||j
||j	�ddd���qxW|S)z2Return the dict to display in the curse interface.�z
{:{width}}ZWIFI)�widthZTITLEz{:>7}ZdBm)rr�Nrrz {}r�_�r*)�itemrZoption)r!rZis_disabledrr Zcurse_add_line�sorted�operator�
itemgetterrZcurse_new_line�lenrZ	get_views)r
r	Z	max_widthr(Zif_name_max_width�msgr,Zhotspot_namerrr�	msg_curse�s.
$&zPlugin.msg_curse)NN)NN)�__name__�
__module__�__qualname__�__doc__rrrZ_check_decoratorZ_log_result_decoratorr#r)r+r8�
__classcell__rr)rrr%s>
r)r<r4Zglances.compatrrZglances.loggerrZglances.plugins.glances_pluginrrZ	wifi.scanrZwifi.exceptionsr�ImportErrorr"rr$rrrrrr�<module>
s "