%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/core.cpython-38.pyc

U

K��^bA�@s6ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlmZmZddlmZddlmZddlmZmZdd	lmZdd
lmZddlmZe�d�Z dZ!d
Z"dZ#dZ$dZ%dZ&dZ'dd�Z(Gdd�d�Z)Gdd�d�Z*Gdd�dej+�Z+Gdd�d�Z,dS)�N)�
schedule_task)�Context)�Skip)�
PALETTE_COLOR�PALETTE_MONO)�
ControllerSet)�Prober)�is_linux_tty�make_screen)�Signal)�SubiquityCoreUI)�arun_commandzsubiquitycore.core����iDKiEKcCsftjj�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�escapeZDEC_SPECIAL_CHARMAP�update�ord�rr�*/usr/share/subiquity/subiquitycore/core.py�extend_dec_special_charmap7s,��rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�KeyCodesFiltera�input_filter that can pass (medium) raw keycodes to the application

    See http://lct.sourceforge.net/lct/x60.html for terminology.

    Call enter_keycodes_mode()/exit_keycodes_mode() to switch into and
    out of keycodes mode. In keycodes mode, the only events passed to
    the application are "press $N" / "release $N" where $N is the
    keycode the user pressed or released.

    Much of this is cribbed from the source of the "showkeys" utility.
    cCs(t�dttj���tj�|_d|_dS)Nz/proc/self/fd/F)	�os�open�str�sys�stdin�fileno�O_RDWR�_fd�	filtering��selfrrr�__init__SszKeyCodesFilter.__init__cCsNt�d�d|_td�}t�|jt|�t�	d|�d|_
t�|jtt�dS)N�enter_keycodes_modeTr�ir)
�log�debugr)�	bytearray�fcntl�ioctlr(�	KDGKBMODE�structZunpack�	_old_mode�	KDSKBMODE�K_MEDIUMRAW)r+�orrrr-Ws
z"KeyCodesFilter.enter_keycodes_modecCs&t�d�d|_t�|jt|j�dS)N�exit_keycodes_modeF)r/r0r)r2r3r(r7r6r*rrrr:cs
z!KeyCodesFilter.exit_keycodes_modecCs�|jr�d}g}t|�}|t|�kr�||d@r4d}nd}|d|kr�||d@dkr�||dd@dkr�||dd@dkr�||dd@d>||dd@B}|d	7}n||d@}|d7}|�|t|��q|S|SdS)
Nr�zrelease zpress r�r�r)r)�len�appendr#)r+�keys�codesr.�r�n�pZkcrrr�filterhs(�
zKeyCodesFilter.filterN)�__name__�
__module__�__qualname__�__doc__r,r-r:rErrrrr Fs
r c@s$eZdZdd�Zdd�Zdd�ZdS)�DummyKeycodesFiltercCsdS�Nrr*rrrr-�sz'DummyKeycodesFilter.enter_keycodes_modecCsdSrKrr*rrrr:�sz&DummyKeycodesFilter.exit_keycodes_modecCs|SrKr)r+r@rArrrrE�szDummyKeycodesFilter.filterN)rFrGrHr-r:rErrrrrJ�srJc@seZdZdd�ZdS)�AsyncioEventLoopcCsP|�d�}|rBt�d|�|��t|tj�sLt|�||jf|_	n
|�
|�dS)N�	exceptionz_exception_handler %r)�getr/r0�stop�
isinstancerZExitMainLoop�type�
__traceback__Z	_exc_infoZdefault_exception_handler)r+�loop�context�excrrr�_exception_handler�s
z#AsyncioEventLoop._exception_handlerN)rFrGrHrVrrrrrL�srLc@s�eZdZeZdd�Zdd�Zd.dd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd/d*d+�Zd0d,d-�ZdS)1�ApplicationcCshd|_|jr"tj�dd��d�|_t|j|j�}|��|_	||_
|j|_d|_|jrZd|_tj
�|jd|j�|_tj|�d�d	d
�i|_|jdk	r�t�|j���|_t�d|j�|js�tdd
���|j|_t�r�t�|_nt�|_t tj�dd��|_!tj
�"|�d��|_#t$�|_%||_&|�'�d|_(t)d�*|j�dddg�}t+||j,|fd�|_,t-�.|�|_/dS)NrZSUBIQUITY_DEBUG��,�/z
.subiquity�run�statesT)�exist_okzLoaded answers %sz/run/casper-no-prompt�wZSUBIQUITY_REPLAY_TIMESCALE�1Zupdatingz{}.controllers)Z	init_args)0Zdebug_flags�dry_runr!�environrN�splitrZmachine_config�make_ui�ui�optsZproject�root�path�join�	state_dir�makedirs�
state_pathZanswers�yamlZ	safe_load�readr/r0r"�close�
run_on_serial�	rich_moder	r �input_filterrJ�floatZscale_factor�exists�updatedr�signal�prober�new_event_loop�
urwid_loop�
__import__�formatr�controllersr�newrT)r+rervZcontrollers_modrrrr,�sT	


�
��zApplication.__init__cCst��}t�|�||_dSrK)�asynciorwZset_event_loop�aio_loop)r+Znew_looprrrrw�s
zApplication.new_event_loopNcsN|jj�����fdd�}���t��tjj�|dk	r@|�t|��dS)Nc�s8t�fdddd����IdH����dk	r4��dS)N)r%�stdout�stderr)r
�startr��
after_hook�cmd�kw�screenrr�_run�s���z3Application.run_command_in_foreground.<locals>._run)rxr�rOrZemit_signalZdisplay_commonZINPUT_DESCRIPTORS_CHANGEDr)r+r�Zbefore_hookr�r�r�rr�r�run_command_in_foreground�s�z%Application.run_command_in_foregroundcCs*|jjD]}|��qt�d|jj�dS)z,Connect signals used in the core controller.zknown signals: %sN)r{�	instancesZregister_signalsr/r0ruZ
known_signals�r+�
controllerrrr�_connect_base_signalss
z!Application._connect_base_signalscGstjj|jf|��SrK)r!rgrhri)r+�partsrrrrkszApplication.state_pathc	CsH|jj}|dkrdSt|�d|j�d��}t�|��|�W5QRXdS)Nr\r^)r{�curr"rk�name�json�dumpZ	serialize)r+r��fprrr�
save_state
s
zApplication.save_statec	Cs�|j�d�|jjr&|j|jjkr&t�z|��Wn"tk
rT|j�d��YnXt|�	d�d��}|�
|j�W5QRXdS)Nzstarting UIz	(skipped)�last-screenr^)rTZenterreZscreensr�rZstart_ui�exitr"rk�write)r+r|r�rrr�
select_screenszApplication.select_screencCs�|��|jj}|dk	r,|j�d�|��|jj}|jj|7_|jjdkr\||j_dS|jjt|jj�krx|��|jj}z|�	|�Wn&t
k
r�t�d|j
�Yq4Yq4XdSq4dS)NZ	completedrzskipping screen %s)r�r{r�rTr�Zend_ui�indexr>r�r�rr/r0r�)r+Z	increment�oldZ	cur_indexr|rrr�_move_screens&
zApplication._move_screencGs|�d�dS�Nr�r��r+�argsrrr�next_screen4szApplication.next_screencGs|�d�dS)N���r�r�rrr�prev_screen7szApplication.prev_screencCs|d|j_|��dSr�)r{r�r�)r+�controller_indexrrr�select_initial_screen:sz!Application.select_initial_screencCs,t�|���}tt|j�}|�|d|�dS)Nz	start: %s)�logging�	getLogger�	full_name�getattr�levelr/)r+rT�descriptionr/r�rrr�report_start_event>szApplication.report_start_eventcCs0t�|���}tt|j�}|�|d||j�dS)Nz
finish: %s %s)r�r�r�r�r�r/r�)r+rTr�Zstatusr/r�rrr�report_finish_eventCszApplication.report_finish_eventcCs$|�d�}tj�|�r t�|�dS)Nr�)rkr!rgrs�unlink)r+�last_screenrrr�_remove_last_screenJs
zApplication._remove_last_screencCs|��|j��dSrK)r�r~rOr*rrrr�OszApplication.exitcs�ddlm�G��fdd�d�}|�����fdd�������fdd��d���fd	d
�	���jd<��jd<�j�jd
<�j�d��dS)Nr)�view_helperscseZdZ��fdd�ZdS)z,Application.run_scripts.<locals>.ScriptStatecs"�j��|_d|_d|_�|_dS)NFr)�__dict__�copy�ns�waiting�
wait_count�scriptsr*�r�r�rrr,csz5Application.run_scripts.<locals>.ScriptState.__init__N)rFrGrHr,rr�rr�ScriptStatebsr�csTt�d�jd�t�jd�j��jr.dS�jdd��_�jrP�j���dS)Nz
running %srr)r/r0r��execr�r�r~�	call_soonr��_run_scriptr+�ssrrr�ksz,Application.run_scripts.<locals>._run_scriptcsl���jd�d�}|sX�jd7_�jdkr>td����d��fdd�d�dSd�_��|�dS)	Nz.*r�
z4no button found matching %r afterwaiting for 10 secscs���SrKrr)�c�patrr�<lambda>{�z4Application.run_scripts.<locals>.c.<locals>.<lambda>��funcr)Zfind_button_matchingrdr��	ExceptionZclick)r�Zbut)r�r+r�r��wait)r�rr�ts
�z"Application.run_scripts.<locals>.ccs(d�_���fdd�}�j�||�dS)NTcs:d�_�dk	r���js6�jdd��_�jr6��dS)NFr)r�r�r)r�r�r�rr�next�sz3Application.run_scripts.<locals>.wait.<locals>.next)r�r~�
call_later)Zdelayr�r�r�r�rr��sz%Application.run_scripts.<locals>.waitr�r�rdg���Q��?)N)Zsubiquitycore.testingr�r�rdr~r�)r+r�r�r)r�r�r�r+r�r�r�r�run_scriptsSs
	

zApplication.run_scriptscCs\|jrtj�d�t}d|_ntj�d�t}d|_tj��|jj	�
|�|jj	��dS)N�asciiFzutf-8T)rpr�utilZset_encodingrrZCanvasCache�clearrxr�Zregister_palette)r+Znew_paletterrr�toggle_rich�s
zApplication.toggle_richcCsL|jjr|dkr|��n.|dkr0|jj��n|jjrH|dkrH|��dS)Nzctrl xZf3)zctrl tZf4)rer`r�rxr�r�ror�)r+�keyrrr�unhandled_input�s
zApplication.unhandled_inputcCs.t�d�|jjD]}|��qt�d�dS)Nzstarting controllerszcontrollers started)r/r0r{r�r�r�rrr�start_controllers�s

zApplication.start_controllersc
Cs�|jjD]D}|�d|j�}tj�|�s(qt|��}|�t	�
|��W5QRXqd}|�d�}tj�|�r�t|��}|����}W5QRXd}t
|jj�D]\}}|j|kr�|}q�|jjd|�D]}|��q�|S)Nr\r�r)r{r�rkr�r!rgrsr"Zdeserializer��loadrm�strip�	enumerateZ
configured)r+r�rkr�r�r�r.rrr�load_serialized_state�s$




z!Application.load_serialized_statecCst|jj||�SrK)r
rer�)r+ZinputfZoutputfrrrr
�szApplication.make_screenc
Cs�t�d�tj|j|�||�dd|jj|jt	|j
d�d�|_t�|�
�|��|_z`|jjrl|�|jj�|j��d}|jr�|��}|j
�|j|�|��|��|j��Wn tk
r�t�d��YnXdS)N�Application.runFT)rS)r�Zhandle_mouseZpop_upsrqr�Z
event_looprzException in controller.run():)r/r0rZMainLooprdr
rqrEr�rLr~rxrr�Z
make_modelZ
base_modelrer�r�r{Zload_allrtr�r�r�r�r�r[r�rM)r+�input�outputZinitial_controller_indexrrrr[�s<


�

�
r�)NN)NN)NN)rFrGrHrrcr,rwr�r�rkr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r[rrrrrW�s.6
@

rW)-r}r2r�r�r!r5r$rrlZsubiquitycore.async_helpersrZsubiquitycore.contextrZsubiquitycore.controllerrZsubiquitycore.paletterrZsubiquitycore.controllersetrZsubiquitycore.proberrZsubiquitycore.screenr	r
Zsubiquitycore.signalsrZsubiquitycore.ui.framerZsubiquitycore.utilsr
r�r/ZK_RAWZK_XLATEr8Z	K_UNICODEZK_OFFr4r7rr rJrLrWrrrr�<module>s>
>

Zerion Mini Shell 1.0