%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/2010/usr/share/subiquity/subiquitycore/ui/views/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/2010/usr/share/subiquity/subiquitycore/ui/views/__pycache__/network.cpython-310.pyc

o

K��^sE�@s4dZddlZddlmZmZddlmZmZddlm	Z	ddl
mZmZm
Z
ddlmZmZddlmZdd	lmZdd
lmZmZmZddlmZmZmZmZmZddlm Z d
dl!m"Z"m#Z#m$Z$m%Z%d
dl&m'Z'ddl(m)Z)e�*d�Z+dd�Z,Gdd�de�Z-e.d�e.d�e.d�e.d�d�Z/Gdd�de)�Z0dS)zS Network Model

Provides network device listings and extended network information

�N)�connect_signal�Text)�	DHCPState�NetDevAction)�
ActionMenu)�back_btn�done_btn�menu_btn)�Pile�
WidgetWrap)�Spinner)�StretchyOverlay)�ColSpec�	TablePile�TableRow)�button_pile�Color�make_action_menu_row�rewrap�screen)�widget_width�)�AddVlanStretchy�BondStretchy�EditNetworkStretchy�ViewInterfaceInfo)�NetworkConfigureWLANStretchy)�BaseViewzsubiquitycore.views.networkcs��fdd�}d|_|S)Ncs4�||g��R�}|�|jj�|��|�|�dS�N)�attach_context�
controller�context�child�show_stretchy_overlay)�self�name�device�stretchy��args�cls��6/usr/share/subiquity/subiquitycore/ui/views/network.py�implDsz_stretchy_shower.<locals>.implT)�opens_dialog)r*r)r-r+r(r,�_stretchy_showerCsr/cs<eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Z�ZS)�NetworkDeviceTablecs ||_||_t��|���dSr)�parent�dev_info�super�__init__�_create)r$r1r2��	__class__r+r,r4MszNetworkDeviceTable.__init__cCstg}tD]$}t|jd|j�}t|dd�}||jjvr(|�|��d||f|f�qt|�}t	|d|jj
|�ttd�t|jj�t|jj
�t|��dd�|td	�g|�g|��}t||jjd
d�|_|j�|jj�|jj
dkr�td
�j|jjj|jjjd�}n#|jj
dkr�td�jd�|jjj�d�}nd�|jj|jj|jjg�}t d|jfdt!�"td|��fdtd�fg�S)N�_action_r.FT�action�[�clip)�wrap�]�)�colspecs�spacing�vlanzVLAN {id} on interface {link})�id�link�bondzbond master for {interfaces}�, )�
interfacesz / �packz  �)#r�getattrr1r%r2�enabled_actions�append�strrr�_actionrr�type�_notes�
_address_rowsr�device_colspecs�table�bind�
heading_table�_�formatrArBrC�joinrDrF�hwaddr�vendor�modelr
r�
info_minor)r$�actionsr9�methr.�menu�trows�infor+r+r,r5RsZ��

���	
����
�zNetworkDeviceTable._createcCs�g}|jjdkr&|jjj}|jdur|�tdj|jd���n|�td��|jjs1|�td��|jj	rB|�td�j|jj	d��|rKd�
|�}|Sd}|S)	N�wlanzssid: {ssid})�ssidz
not connectedzenslaved to {device})r&rE�-)r2rNra�configrbrKrUrV�is_connected�bond_masterrW)r$�notesrdr+r+r,rO�s&

��
�zNetworkDeviceTable._notesc
s�g}d|jj|jjfd|jj|jjffD]w\}}}|jrwtdj|d���|j}|r6|�	�fdd�|D��q|j
tjkrUt
|jjjjdd�}d	|_|��|��|f�q|j
tjkrg|��ttd
��f�q|j
tjkrv|��td�f�q|jr�|�ttd��td
�|j��f�qt|�dkr�|jjs�|jj}|dur�d}|�ttd��t|�f�g}|D]\�}	|�ttd��d|	fg��q�|S)N��zDHCPv{v})�vcsg|]}�t|�f�qSr+)r)�.0�addr��labelr+r,�
<listcomp>�sz4NetworkDeviceTable._address_rows.<locals>.<listcomp>�left��aligng333333�?z	timed outrc�staticrErrH�disabledr>)r2�dhcp4�static4�dhcp6�static6�enabledrrV�	addresses�extend�stater�PENDINGrr1r �app�aio_loop�rate�startrK�	TIMED_OUTrU�RECONFIGURErW�len�is_used�disabled_reasonr)
r$�address_inforj�dhcp_status�
static_config�addrs�s�reason�rows�valuer+rmr,rP�sL����
��z NetworkDeviceTable._address_rowscCs�||_|jjdj}|jdd�|j�|jdd�|j�|jdd�|���|j�	dt
|jj��|j�d|���dS)Nrrr>�)
r2rR�
table_rows�base_widget�cells�set_textr%rNrO�remove_rowsr��insert_rowsrP)r$r2�	first_rowr+r+r,�update�s	zNetworkDeviceTable.update)	�__name__�
__module__�__qualname__r4r5rOrPr��
__classcell__r+r+r6r,r0Ls6%r0zRA wifi device was detected but the necessary support packages were not
available.
z+Wifi support packages are being installed.
z@Wifi support packages failed to install. Please check the logs.
z>Wifi support packages will be installed in the target system.
)�
NOT_AVAILABLE�
INSTALLING�FAILED�DONEcs�eZdZed�Zed�Z	d.�fdd�	Zdd�Zdd	�Zd
e_	e
e�Ze
e
d�Ze
e
d�Ze
e�Zd
d�Zd
e_	dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd/d$d%�Zd&d'�Zd/d(d)�Zd/d*d+�Z d/d,d-�Z!�Z"S)0�NetworkViewzNetwork connectionsz�Configure at least one interface this server can use to talk to other machines, and which preferably provides sufficient access for updates.�
NOT_NEEDEDcs(||_i|_g|_tddd�|_tdd�tdd�tddd	�d
�|_ttdd�d
D��gd|jd�|_	t
|j	g�|_|D]}|�|�q;t
td�|jd�|_t|jg�}d|_|j|g}ttd|jd�ttd�|jd�g�|_t
d|jfg�|_d|_d|_|�|�t��t||jdt|j�d��dS)NrH�centerrqr)�rpad�)�	min_widthT)�
can_shrinkr�)rr�rhcSsg|]	}t�t|���qSr+)rr[r)rk�headerr+r+r,ro�s�z(NetworkView.__init__.<locals>.<listcomp>)rH�NAME�TYPE�NOTESrHr>)r@r?zCreate bond)�on_pressrp�TBD�BackrGF)r��buttons�
focus_buttons�excerpt) r �dev_name_to_table�cur_netdev_namesr�errorrrQrrrTr
�device_pile�new_linkr	rU�_create_bond�_create_bond_btnrrrr�doner�cancelr��bottom�"wlan_support_install_state_showing�
error_showing�%update_for_wlan_support_install_stater3r4rr�)r$r �netdev_infos�wlan_support_install_stater2�bpr�r6r+r,r4�sT
����	
����
�zNetworkView.__init__c�sR�|jjj|j�|�ddd�IdH}t|||�}|�|jj�d��|�|�dS)NzLoading infoT)�
can_cancel�INFO)	r r~�wait_with_text_dialog�get_info_for_netdevrrr!r"r#)r$r%r`r'r+r+r,�
_show_INFO"s��zNetworkView._show_INFOcCs|jjj�|�|j��dSr)r r~r�create_taskr�r%�r$r%r2r+r+r,�_action_INFO*s

�zNetworkView._action_INFOTrhricCs2t|||���}|�|jj�|��|�|�dSr�r�get_candidate_bond_member_namesrr r!r"r#)r$r%r2r'r+r+r,�_action_EDIT_BOND4�

�zNetworkView._action_EDIT_BONDcCsL|jj�|��|j�|j�|�|�Wd�dS1swYdSr)r r!r"�delete_linkr%�del_linkr�r+r+r,�_action_DELETE<s"�zNetworkView._action_DELETEcCs(|\}}|j}|d�|j|j�|�dS)Nz{}/{})r2rVr%)r$�senderr9�netdev_tabler]r2r+r+r,rMAszNetworkView._actioncCs`t�d|�|r
td�}ntd�}|jjd�|�tdt|jjd�t|jjd��|j_dS)Nzview route_watcher %s�DonezContinue without networkr�r)	�log�debugrUr�r��	set_label�maxr�width)r$�routesrnr+r+r,�update_default_routesFs
�z!NetworkView.update_default_routescCsdt|jjj�}|��ttttd��|g�gdd�}||j	�
�ftd�|j	�
�fg|j	jdd�<dS)NzApplying changesr�rqrHr)rr r~rr�rrrrUr��options�contents)r$r��cr+r+r,�show_apply_spinnerSs
����zNetworkView.show_apply_spinnercCs(t|jj�dkrg|jjdd�<dSdS)Nr>r)r�r�r�)r$r+r+r,�hide_apply_spinneras�zNetworkView.hide_apply_spinnercCs�t�d|j|j|jv�|j|jvr|�|�dS|j�|j�|j��|j�|j�}t	||�}||j|j<||j
�d�fg|j
j|d|d�<dS)Nznew_link %s %srGr)
r�r�r%r�r��update_linkrK�sort�indexr0r�r�r�)r$�new_dev_info�netdev_i�device_tabler+r+r,r�es�


�zNetworkView.new_linkcCsft|jt�rt|jjd�r|jj�|�t�d|j|j|j	v�|j|j	vr(dS|j
|j�|�dS)Nr�zupdate_link %s %s)�
isinstance�_wr
�hasattrr'r�r�r�r%r�r�r�)r$r2r+r+r,r�ts�zNetworkView.update_linkcCspt|jj�d}|jj|k}|jj|=|r|j��dS|jj��s0|jjd7_|jj��r"|jj��dS)Nr)r�r�r��focus_position�_select_last_selectable�focus�
selectable�_select_first_selectable)r$r��
new_length�refocusr+r+r,�_remove_rows
�zNetworkView._remove_rowcCs�t�d|j|j|jv�|jr|jrdS|j|jvr1|j�|j�}|�|d�|j|=|j|j=t	|j
t�rI|j
j}t
|dd�|urK|��dSdSdS)Nzdel_link %s %srr&)r�r�r%r��
is_virtual�
has_configr�r�r�r�r�r
r'rI�remove_overlay)r$r2r�r'r+r+r,r��s"�
�zNetworkView.del_linkcCsBg}|j��D]}|j}|jdvrq|jdurq|�|j�q|S)N)rArD)r��valuesr2rNrfrKr%)r$�namesrRr2r+r+r,r��s

z+NetworkView.get_candidate_bond_member_namesNcCs2t|d|���}|�|jj�d��|�|�dS)N�add_bondr�)r$r�r'r+r+r,r��r�zNetworkView._create_bondcCsz|dkrdS|jrd}nd}|jr|d}n|}d|_t|}tt|�dd�|j��ftd�|j��fg|jj||�<dS)Nr�r>rTr�rqrH)r�r�� wlan_support_install_state_textsrrr�r�r�)r$r|�start_i�end_i�textr+r+r,r��s
�z1NetworkView.update_for_wlan_support_install_statecCs|jsd}}d|_nd}d}t�|j�|j��ftd�|j��fg|jj||�<|dkr=|d}|j�d|j	f�dS|dkrI|j�d�dS|d	krU|j�d
�dS|dkra|j�d�dS|d
krm|j�d�dS|dkry|j�d�dS|j�d�dS)NrTr>rHz
stop-networkdz$Stopping systemd-networkd-failed: %r�applyzHNetwork configuration could not be applied; please verify your settings.�timeoutz=Network configuration timed out; please verify your settings.�downz"Downing network interfaces failed.zadd-vlanzFailed to add a VLAN tag.zrm-devz%Failed to delete a virtual interface.z>An unexpected error has occurred; please verify your settings.)
r�r�
info_errorr�r�r�rr�r��stderr)r$r9r`r�r��excr+r+r,�show_network_error�s0�
�zNetworkView.show_network_errorcCs$|jrg|jjdd�<|j��dS)Nrr>)r�r�r�r r�)r$�resultr+r+r,r��szNetworkView.donecCs|j��dSr)r r�)r$�buttonr+r+r,r��szNetworkView.cancel)r�r)#r�r�r�rU�titler�r4r�r�r.r/r�_action_EDIT_WLANr�_action_EDIT_IPV4�_action_EDIT_IPV6r�_action_ADD_VLANr�r�rMr�r�r�r�r�r�r�r�r�r�rr�r�r�r+r+r6r,r��s:�8





r�)1�__doc__�logging�urwidrr�subiquitycore.models.networkrr�subiquitycore.ui.actionmenur�subiquitycore.ui.buttonsrrr	�subiquitycore.ui.containerr
r�subiquitycore.ui.spinnerr�subiquitycore.ui.stretchyr
�subiquitycore.ui.tablerrr�subiquitycore.ui.utilsrrrrr�subiquitycore.ui.widthr�"network_configure_manual_interfacerrrr� network_configure_wlan_interfacer�subiquitycore.viewr�	getLoggerr�r/r0rUr�r�r+r+r+r,�<module>s2
		�

Zerion Mini Shell 1.0