AlkantarClanX12

Your IP : 3.17.166.157


Current Path : /usr/lib/python3.6/site-packages/tuned/utils/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/tuned/utils/__pycache__/nettool.cpython-36.pyc

3

�<�eF�@sHdgZddlZddlTddlZejj�ZGdd�d�Zdd�Z	ie	_
dS)�ethcard�N)�*c@s~eZdZddgddgddgddgdd	gd
d�ZdZd
d�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS) �Nettool������ ri�i�?)�
�di�i�	i'�autoFcCsb||_|j�tjd||j|j|j|jf�tjd||j|j	f�tjd||j
|jf�dS)Nz1%s: speed %s, full duplex %s, autoneg %s, link %sz"%s: supports: autoneg %s, modes %sz$%s: advertises: autoneg %s, modes %s)�
_interface�update�log�debug�speed�full_duplex�autoneg�link�supported_autoneg�supported_modes�advertised_autoneg�advertised_modes)�self�	interface�r�/usr/lib/python3.6/nettool.py�__init__s
 zNettool.__init__cCs4d|_d|_d|_d|_g|_d|_g|_d|_dS)NrF)rrrrrrrr)rrrr�
_clean_status"szNettool._clean_statuscCs8d}x.|D]&}||j|d|dr(dnd7}q
W|S)Nrr)�_advertise_values)rZmodes�mode�mrrr�_calculate_mode.s
&zNettool._calculate_modecCs<|j|krdS|jsdSdtdd|jd|r.dndgdd	�kS)
NTFr�ethtoolz-sr�onZoff)�	close_fds)rr�callr)r�enablerrr�_set_autonegotiation5s

zNettool._set_autonegotiationcCs.|jd�sdSdtdd|jdd|gdd�kS)	NTFrr%z-sZ	advertisez0x%03x)r')r*r(r)r�valuerrr�_set_advertise>s
zNettool._set_advertisecCs<d}x"|jD]}|d|kr|d}qW|dkr4|SdSdS)Nri�)r)r�maxr"rrr�
get_max_speedDszNettool.get_max_speedcCs6|js|jrdS|j|jd�r.|j�dSdSdS)NFrT)�	_disabledrr,r!r)rrrr�
set_max_speedNszNettool.set_max_speedcCs�|js|jrdSd}xD|jD]:}|dkr,q||kr||j|d7}||j|d7}qW||j|j�@}tjd|j||f�|j|�r�|j	�dSdSdS)NFrrrz)%s: set_speed(%d) - effective_mode 0x%03xT)
r/rr!r$rrrrr,r)rrr"ZamZeffective_moderrr�	set_speedYs
zNettool.set_speedc
Cs"|jr
dStd|jgttddd�}tddg|jtddd�}|j�d}|j�d}|d	kr�tjd
|j�tjd|j|j	dd
�f�|j
�d|_dS|j
�tjd�}tjd�}d}�xb|j
d�D�]R}|jd��rj|dd)�}	|	dkr�d}nt|	dk�rd}nd|	dk�rd}nT|	dk�r"d}nD|	dk�r2d}n4|	dk�rBd}n$|	dk�rRd}n|	d k�rbd!}nd}~	q�|dk�r�y|j|�jd�|_Wnd"|_YnXd}q�|dk�r�|d#k|_d}q�|dk�r�|d$k�p�|d%k|_d}q�|dk�r�|d$k|_d}q�|dk�rnyLx@|j
�D]4}
|j|
�jdd&�\}}|jjt|�|d#kf��qW~
~~Wn|jjd*�YnXq�|dk�r�|d'k|_d}q�|dk�ryV|d(k�r�x@|j
�D]4}
|j|
�jdd&�\}}|jjt|�|d#kf��q�W~
~~Wn|jjd+�YnXq�|d!kr�|d'k|_d}q�WdS),Nr%T)�stdout�stderrr'�universal_newlinesZsedzs/^\s*//;s/:\s*/:\n/g)�stdinr2r4r'rr�z*%s: some errors were reported by 'ethtool'z%s: %s�
z\nz(\d+)z(\d+)baseT/(Half|Full)�wait�:ZSpeedrZDuplexZduplexzAuto-negotiationrz
Link detectedrzSupported link modesrzSupports auto-negotiationrzAdvertised link modesrzAdvertised auto-negotiationr��ZFull�yesr&rZYeszNot reported���)r:T)r:T)r/�Popenr�PIPEr2ZcommunicaterZwarningr�replacer �re�compile�split�endswith�match�grouprrrrr�append�intrrr)
rZ	p_ethtoolZp_filter�output�errorsZre_speedZre_mode�state�lineZsectionr#�s�drrrrns�























zNettool.updateN)�__name__�
__module__�__qualname__r!r/rr r$r*r,r.r0r1rrrrrr	s 	
rcCs"|tjkrt|�tj|<tj|S)N)r�listr)rrrrr�s
)�__all__Z
tuned.logsZtuned�
subprocessr@Zlogs�getrrrrQrrrr�<module>s
H