HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/share/netplan/netplan/__pycache__/terminal.cpython-38.pyc
U

��~f��@s`dZddlZddlZddlZddlZddlZGdd�de�ZGdd�de�Z	Gdd�de�Z
dS)	z
Terminal / input handling
�Nc@sVeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zddd�Z	ddd�Z
ddd�Zd
S)�Terminalz@
    Do minimal terminal mangling to prompt users for input
    cCs||_d|_d|_|��dS�N)�fd�
orig_flags�	orig_term�save)�selfr�r	�&/usr/share/netplan/netplan/terminal.py�__init__"szTerminal.__init__cCsPtj��rLt�|j�}|dtjB|d<|dtjB|d<t�|jtj	|�dS�N��
�sys�stdin�isatty�termios�	tcgetattrrZICANONZECHO�	tcsetattrZTCSANOW�r�attrsr	r	r
�enable_echo(s

zTerminal.enable_echocCsTtj��rPt�|j�}|dtj@|d<|dtj@|d<t�|jtj	|�dSrrrr	r	r
�disable_echo/s

zTerminal.disable_echocCs,t�|jtj�}t�|jtj|tjB�dSr��fcntlr�F_GETFL�F_SETFL�os�
O_NONBLOCK�r�flagsr	r	r
�enable_nonblocking_io6szTerminal.enable_nonblocking_iocCs.t�|jtj�}t�|jtj|tj@�dSrrrr	r	r
�disable_nonblocking_io:szTerminal.disable_nonblocking_io�xNcCs�td�t�}|�|�|��|��|s0d}td�|��|}|dkr�td�|tt|���dd�t�t	j
gggd�z&t	j
��}|d	kr�|�|�t
��Wntk
r�YnX|d8}qB|�|�t��d
S)a�
        Get a "confirmation" input from the user, for at most (timeout)
        seconds. Optionally, customize the message to be displayed.

        timeout -- timeout to wait for input (default 120)
        message -- optional customized message ("Press ENTER to (message)")

        raises:
        InputAccepted -- the user confirmed the changes
        InputRejected -- the user rejected the changes
        z%Do you want to keep these settings?

zaccept the new configurationz&Press ENTER before the timeout to {}

rz%Changes will revert in {:>{}} seconds�
)�end��
N)�print�dictrrr!�format�len�str�selectrr�read�reset�
InputAccepted�	TypeError�
InputRejected)r�timeout�message�settingsZtimeout_now�cr	r	r
�get_confirmation_input>s,





zTerminal.get_confirmation_inputcCsTt�|jtj�}d}tj��r*t�|j�}|dk	rD|�||d��n||_	||_
dS)z�
        Save the terminal's current attributes and flags

        Optional argument:
            - dest: if set, save settings to this dict
        N)r �term)rrrrrrrr�updaterr)r�destrrr	r	r
rps
�
z
Terminal.savecCsdd}d}|dk	r&|�d�}|�d�}n|j}|j}tj��rNt�|jtj	|�t
�
|jt
j|�dS)z�
        Reset the terminal to its original attributes and flags

        Optional argument:
            - orig: if set, reset to settings from this dict
        Nr8r )�getrrrrrrrrZ	TCSAFLUSHrr)r�origrrr	r	r
r/�s

zTerminal.reset)r#N)N)N)�__name__�
__module__�__qualname__�__doc__rrrr!r"r7rr/r	r	r	r
rs
2
rc@seZdZdZdS)r0z Denotes has accepted inputN�r=r>r?r@r	r	r	r
r0�sr0c@seZdZdZdS)r2z) Denotes that the user has rejected inputNrAr	r	r	r
r2�sr2)r@rrrr-r�objectr�	Exceptionr0r2r	r	r	r
�<module>sy