%PDF- %PDF-
Direktori : /snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/ |
Current File : //snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/controller.cpython-38.pyc |
U K��^ � @ sV d dl mZmZ d dlZe�d�ZG dd� de�ZG dd� de�ZG dd � d e�Z dS ) � )�ABC�abstractmethodNzsubiquitycore.controllerc @ s e Zd ZdZdS )�Skipz@Raise this from a controller's start_ui method to skip a screen.N)�__name__� __module__�__qualname__�__doc__� r r �0/usr/share/subiquity/subiquitycore/controller.pyr s r c @ s� e Zd ZdZg ZdZdd� Zdd� Zdd� Ze d d � �Z edd� �Ze d d� �Z dd� Zdd� Zdd� Zddd�Zdd� Zddd�ZdS )�BaseControllerzBase class for controllers.Nc C s� t | �jd td� � | _|j| _|j| _|j| _|| _| jjj | jdd�| _|j �| ji �| _ | jd k r|t | jj| j�| _d S )NZ Controller�DEBUG)Z childlevel)�typer �len�nameZui�signalZopts�app�contextZchildZanswers�get� model_name�getattrZ base_modelZmodel)�selfr r r r �__init__ s zBaseController.__init__c C s8 g }| j D ]\}}|�|t| |�f� q | j�|� dS )z6Defines signals associated with controller from model.N)�signals�appendr r Zconnect_signals)r r Zsig�cbr r r �register_signals* s zBaseController.register_signalsc C s dS )aG Called just before the main loop is started. At the time this is called, all controllers and models and so on have been created. This is when the controller should start interacting with the outside world, e.g. probing for network devices or start making connections to the snap store. Nr �r r r r �start1 s zBaseController.startc C s d S �Nr r r r r �cancel; s zBaseController.cancelc C s$ | j jj}t|t�r|j}q || kS r )r ZcontrollersZcur� isinstance�RepeatedController�orig)r �instr r r �showing? s zBaseController.showingc C s dS )z_Start running this controller's UI. This method should call self.ui.set_body. Nr r r r r �start_uiF s zBaseController.start_uic C s dS )a Stop running this controller's UI. This method doesn't actually need to remove this controller's UI as the next one is about to replace it, it's more of a hook to stop any background tasks that can be stopped when the UI is not running. Nr r r r r �end_uiM s zBaseController.end_uic C s d S r r r r r r � serializeV s zBaseController.serializec C s |d k rt d�| ���d S )Nz missing deserialize method on {})� Exception�format)r �datar r r �deserializeY s zBaseController.deserialize� c c s� |� � D ]~\}}t| d�||�d �}|d krBt| d�|�dd� �}t||�}ddlm} ||�}t|j| �rz|j�d|� ||_d V qd V |j D ]} | � � q�|�� |r�|jj s�td��|�d � d S ) Nz_action_clean_{}_{}z_action_clean_{}c S s | S r r )�xr r r �<lambda>e � z1BaseController._enter_form_data.<locals>.<lambda>r )�SelectorZselectzanswers left form invalid!)�itemsr r) Zsubiquitycore.ui.selectorr0 r ZwidgetZ_emit�value�_fieldsZvalidateZ validatedZdone_btnZenabledr( Z_click_done)r Zformr* ZsubmitZclean_suffix�k�v�cZfieldr0 Zbfr r r �_enter_form_data` s. � zBaseController._enter_form_datac c s |D ]}| � |�E d H qd S r )Z_answers_action)r Zactions�actionr r r �_run_actionsv s zBaseController._run_actionsc C sV |d krd| j j }zt|� W n tk r6 Y d S X | j j�|| j||d � d S )Ng�������?g�������?)r Zscale_factor�next� StopIterationZaio_loopZ call_later� _run_iterator)r �itZdelayr r r r<