%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/tui.cpython-310.pyc

o

K��^�3�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
ddlmZddlmZddlmZddlmZdd	lmZe�d
�Zdd�Zd
ZdZGdd�de
�ZdS)�N)�
schedule_task)�Application)�
PALETTE_COLOR�PALETTE_MONO)�make_screen)�Skip)�
LoadingDialog)�SubiquityCoreUI)�astart_commandzsubiquitycore.tuicCsftjj�td�dtd�dtd�dtd�dtd	�d
td�dtd
�dtd�dtd�tjjtd�i	�dS)Nu▸�>u◂�<u▾�vu▴�^u✓�+u•�*u▄�=u▀u█u│)�urwid�escape�DEC_SPECIAL_CHARMAP�update�ord�rr�)/usr/share/subiquity/subiquitycore/tui.py�extend_dec_special_charmap(s�
�rg�������?g�?cs�eZdZeZ�fdd�Zd/dd�Zdd�Zd0dd	�Zd
d�Z	dd
�dd�Z
dd�Zdd�Zdd�Z
d0dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd/d&d'�Zd/d(d)�Zd1�fd+d,�	Z�fd-d.�Z�ZS)2�TuiApplicationcsxt��|�|��|_i|_|jdur-t�|j���|_t�	d|j�|j
s-tdd���|j
|_d|_d|_d|_dS)NzLoaded answers %sz/run/casper-no-prompt�w)�super�__init__�make_ui�ui�answers�yaml�	safe_load�read�log�debug�dry_run�open�close�
run_on_serial�	rich_mode�
urwid_loop�
cur_screen�fg_proc)�self�opts��	__class__rrrCs


zTuiApplication.__init__Ncsb�jdur	td���jj������fdd�}���t��tjj�|dur*|�t	|��dS)Nz#cannot run two fg processes at oncec�sh�t�fdddd����IdH�_}|��IdHd�_t�dt�������dur2��dSdS)N)�stdin�stdout�stderrr)r
r-�communicate�os�	tcsetpgrp�getpgrp�start)�proc��
after_hook�cmd�kw�screenr.rr�_run[s����
�z6TuiApplication.run_command_in_foreground.<locals>._run)
r-�	Exceptionr+r?�stopr�emit_signal�display_common�INPUT_DESCRIPTORS_CHANGEDr)r.r=�before_hookr<r>r@rr;r�run_command_in_foregroundUs
�z(TuiApplication.run_command_in_foregroundc�sv�|j�d�|jjr|j|jjvrt�z|��}t�|�r$|IdH}n|}Wnty5|j�	d��w||_
|S)Nzstarting UIz	(skipped))�context�enterr/�screens�namerr�inspect�iscoroutine�exitr,)r.�new�
maybe_view�viewrrr�make_view_for_controller|s �
��z'TuiApplication.make_view_for_controllerc�s��d����fdd�}d�j_�j�t|�}z |IdH}W�r-�IdH|dur+|�|Sd�j_|��|S�rG�IdH|durF|�wwd�j_|��w)a�Wait for something but tell the user if it takes a while.

        When waiting for something that can take an unknown length of
        time, we want to tell the user if it takes more than a moment
        (defined as MAX_BLOCK_TIME) but make sure that we display any
        indication for long enough that the UI is not flickering
        incomprehensibly (MIN_SHOW_PROGRESS_TIME).
        Ncs$d�j_�j�t�t�����dS)NF)r�block_input�aio_loop�create_task�asyncio�sleep�MIN_SHOW_PROGRESS_TIMEr��
min_show_taskr.�showrr�_show�s
�
z3TuiApplication._wait_with_indication.<locals>._showTF)rrSrT�
call_later�MAX_BLOCK_TIME�cancel)r.�	awaitabler[�hider\�show_handle�resultrrYr�_wait_with_indication�s,�	
��
�
z$TuiApplication._wait_with_indicationcCst��N)�NotImplementedError�r.rrr�
show_progress��zTuiApplication.show_progressF)�
can_cancelc�st�d�d�|r!t|tj�s|��fdd�}�j�|��}�nd�����fdd�}�fdd�}��|||�IdHS)Nc�s��IdHSrerr)�origrrr�s�
z/TuiApplication.wait_with_text_dialog.<locals>.wcs,t�jj�j�����jjj��jd�dS)N)�width)rr�bodyrT�show_overlayrlr)�ld�messager.�task_to_cancelrr�	show_load�s�z7TuiApplication.wait_with_text_dialog.<locals>.show_loadcs���dSre)r(r)rorr�	hide_load��z7TuiApplication.wait_with_text_dialog.<locals>.hide_load)�
isinstancerV�TaskrTrUrd)r.r`rprjrrrrsr)rorprkr.rqr�wait_with_text_dialog�s�
�z$TuiApplication.wait_with_text_dialogc�s�|�||j�IdHSre)rdrh)r.r`rrr�wait_with_progress�s�z!TuiApplication.wait_with_progressc�s��|dur
|IdH|jd}|_|dur|j�d�|��|jj}	|jj|7_|jjdkr8||j_dS|jjt|jj�krH|��dS|jj}z	|�	|�IdHWSt
yet�d|j
�Yq#typ||j_�w)N�	completedTrzskipping screen %s)r,rHrN�end_ui�controllers�index�len�	instances�currRrr$r%rKrA)r.�	increment�coro�old�	cur_indexrOrrr�_move_screen�s4�
�zTuiApplication._move_screenc�s6�|�|�||��IdH}|dur|j�|�dSdSre)rxr�r�set_body)r.r�r�rQrrr�move_screen�s�

��zTuiApplication.move_screencCs|j�|�d|��dS)N��rTrUr�)r.r�rrr�next_screen��zTuiApplication.next_screencCs|j�|�dd��dS)N���r�rgrrr�prev_screen�r�zTuiApplication.prev_screencCs|��dSre)r�rgrrr�select_initial_screen�rtz$TuiApplication.select_initial_screencs�ddlm�G��fdd�d�}|�����fdd�������fdd��d���fd	d
�	���jd<��jd<�j�jd
<�j�d��dS)Nr)�view_helperscseZdZ��fdd�ZdS)z/TuiApplication.run_scripts.<locals>.ScriptStatecs"�j��|_d|_d|_�|_dS)NFr)�__dict__�copy�ns�waiting�
wait_count�scriptsrg�r�r�rrr
s
z8TuiApplication.run_scripts.<locals>.ScriptState.__init__N)�__name__�
__module__�__qualname__rrr�rr�ScriptState	sr�csXt�d�jd�t�jd�j��jrdS�jdd��_�jr*�j���dSdS)Nz
running %srr�)r$r%r��execr�r�rT�	call_soonr��_run_scriptr.�ssrrr�s�z/TuiApplication.run_scripts.<locals>._run_scriptcsl���jd�d�}|s,�jd7_�jdkrtd����d��fdd�d�dSd�_��|�dS)	Nz.*r��
z4no button found matching %r afterwaiting for 10 secscs���Srerr)�c�patrr�<lambda>"sz7TuiApplication.run_scripts.<locals>.c.<locals>.<lambda>��funcr)�find_button_matchingrr�rA�click)r��but)r�r.r�r��wait)r�rr�s
�z%TuiApplication.run_scripts.<locals>.ccs(d�_���fdd�}�j�||�dS)NTcsBd�_�dur
���js�jdd��_�jr��dSdSdS)NFr�)r�r�r)r�r�r�rr�next*s
�z6TuiApplication.run_scripts.<locals>.wait.<locals>.next)r�rTr])�delayr�r�r�r�rr�'sz(TuiApplication.run_scripts.<locals>.waitr�r�rg���Q��?re)�subiquitycore.testingr�r�rrTr])r.r�r�r)r�r�r�r.r�r�r�r�run_scripts�s
	

zTuiApplication.run_scriptscCs||jkrdS|��dSre)r*�toggle_rich)r.�richrrr�set_rich:s
zTuiApplication.set_richcCs\|jrtj�d�t}d|_ntj�d�t}d|_tj��|jj	�
|�|jj	��dS)N�asciiFzutf-8T)r*r�util�set_encodingrr�CanvasCache�clearr+r?�register_palette)r.�new_paletterrrr�?s
zTuiApplication.toggle_richcCsX|jjr|dkr|��dS|dkr|jj��dS|jjr(|dvr*|��dSdSdS)Nzctrl x�f3)zctrl t�f4)r/r&rNr+r?r�r)r�)r.�keyrrr�unhandled_inputLs�zTuiApplication.unhandled_inputcCsiSrerrgrrr�extra_urwid_loop_argsTriz$TuiApplication.extra_urwid_loop_argscCst|jj||�Sre)rr/r�)r.�inputf�outputfrrrrWszTuiApplication.make_screenc	Cs|t�tjtj�|�||�}|�t�tj|jf|dd|j	tj
|jd�d�|����|_
t�|��|j
��|��dS)NFT)�loop)r?�handle_mouse�pop_upsr��
event_loop)�signal�SIGTTOU�SIG_IGNrr�rr�MainLooprr��AsyncioEventLooprTr�r+rr�r9r�)r.�input�outputr?rrr�start_urwidZs"
���
zTuiApplication.start_urwidTc�s&�t���IdH|r|��dSdSre)rr9r�)r.r�r0rrr9ls
��zTuiApplication.startcsX|jjr|�|jj�zt���W|jdur|j��dSdS|jdur+|j��wwre)r/r�r�r�runr+rBrgr0rrr�qs
��zTuiApplication.run)NNre)T)r�r�r�r	rrrGrRrdrhrwrxr�r�r�r�r�r�r�r�r�r�rr�r9r��
__classcell__rrr0rr?s0
'
!�
@


r)rVrL�loggingr6r�rr!�subiquitycore.async_helpersr�subiquitycore.corer�subiquitycore.paletterr�subiquitycore.screenr�subiquitycore.tuicontrollerr�subiquitycore.ui.utilsr�subiquitycore.ui.framer	�subiquitycore.utilsr
�	getLoggerr$rr^rXrrrrr�<module>s(


Zerion Mini Shell 1.0