CasperSecurity

Current Path : /usr/share/netplan/netplan/__pycache__/
Upload File :
Current File : //usr/share/netplan/netplan/__pycache__/terminal.cpython-38.pyc

U

P�b��@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�rZattrsr	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
        Nr7r)�getrrrrrrrrZ	TCSAFLUSHrr)r�origrrr	r	r
r.�s

zTerminal.reset)r"N)N)N)�__name__�
__module__�__qualname__�__doc__rrrr r!r6rr.r	r	r	r
rs
2
rc@seZdZdZdS)r/z Denotes has accepted inputN�r<r=r>r?r	r	r	r
r/�sr/c@seZdZdZdS)r1z) Denotes that the user has rejected inputNr@r	r	r	r
r1�sr1)r?rrrr,r�objectr�	Exceptionr/r1r	r	r	r
�<module>sy
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY