%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/netplan/netplan/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/netplan/netplan/__pycache__/terminal.cpython-36.pyc

3

�Bd]��@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|_|j�dS)N)�fd�
orig_flags�	orig_term�save)�selfr�r�&/usr/share/netplan/netplan/terminal.py�__init__"szTerminal.__init__cCsFtj|j�}|dtjB|d<|dtjB|d<tj|jtj|�dS)N�)�termios�	tcgetattrr�ICANON�ECHO�	tcsetattr�TCSANOW)r�attrsrrr	�enable_echo(szTerminal.enable_echocCsJtj|j�}|dtj@|d<|dtj@|d<tj|jtj|�dS)Nr)rr
rrrrr)rrrrr	�disable_echo.szTerminal.disable_echocCs,tj|jtj�}tj|jtj|tjB�dS)N)�fcntlr�F_GETFL�F_SETFL�os�
O_NONBLOCK)r�flagsrrr	�enable_nonblocking_io4szTerminal.enable_nonblocking_iocCs.tj|jtj�}tj|jtj|tj@�dS)N)rrrrrr)rrrrr	�disable_nonblocking_io8szTerminal.disable_nonblocking_io�xNcCs�td�t�}|j|�|j�|j�|s0d}tdj|��|}x�|dkr�tdj|tt|���dd�tjt	j
gggd�y&t	j
j�}|d	kr�|j|�t
��Wntk
r�YnX|d8}qDW|j|�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�select�sys�stdin�read�reset�
InputAccepted�	TypeError�
InputRejected)r�timeout�message�settingsZtimeout_now�crrr	�get_confirmation_input<s,





zTerminal.get_confirmation_inputcCsFtj|jtj�}tj|j�}|dk	r6|j||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)rrrrr
�updaterr)r�destrrrrr	rnsz
Terminal.savecCsZd}d}|dk	r&|jd�}|jd�}n|j}|j}tj|jtj|�tj|jtj|�dS)z�
        Reset the terminal to its original attributes and flags

        Optional argument:
            - orig: if set, reset to settings from this dict
        Nr4r)	�getrrrrrZ	TCSAFLUSHrr)r�origrrrrr	r+~s
zTerminal.reset)rN)N)N)�__name__�
__module__�__qualname__�__doc__r
rrrrr3rr+rrrr	rs
2
rc@seZdZdZdS)r,z Denotes has accepted inputN)r9r:r;r<rrrr	r,�sr,c@seZdZdZdS)r.z) Denotes that the user has rejected inputN)r9r:r;r<rrrr	r.�sr.)r<rrrr'r(�objectr�	Exceptionr,r.rrrr	�<module>st

Zerion Mini Shell 1.0