PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /proc/thread-self/root/proc/self/root/proc/self/root/opt/saltstack/salt/extras-3.10/rads/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //proc/thread-self/root/proc/self/root/proc/self/root/opt/saltstack/salt/extras-3.10/rads/_input.py |
"""Functions for obtaining CLI input""" import termios import sys import os from . import color def get_keypress() -> str: """Get a single keypress, the ugly POSIX way""" fileno = sys.stdin.fileno() old = termios.tcgetattr(fileno) new = termios.tcgetattr(fileno) new[3] = new[3] & ~termios.ICANON & ~termios.ECHO new[6][termios.VMIN] = 1 new[6][termios.VTIME] = 0 termios.tcsetattr(fileno, termios.TCSANOW, new) key = None try: key = str(os.read(fileno, 4), 'ascii') finally: termios.tcsetattr(fileno, termios.TCSAFLUSH, old) keylist = { '\t': 'TAB', '\n': 'ENTER', '\x7f': 'BACKSPACE', '\x1b': 'ESC', '\x1b[Z': 'BACKTAB', '\x1bOH': 'HOME', '\x1bOP': 'F1', '\x1bOQ': 'F2', '\x1bOR': 'F3', '\x1bOS': 'F4', '\x1b[15': 'F5', '\x1b[17': 'F6', '\x1b[18': 'F7', '\x1b[19': 'F8', '\x1b[20': 'F9', '\x1b[21': 'F10', '\x1b[23': 'F11', '\x1b[24': 'F12', '\x1b[A': 'ARROW_UP', '\x1b[B': 'ARROW_DN', '\x1b[C': 'ARROW_RT', '\x1b[D': 'ARROW_LT', } return key if key not in keylist else keylist[key] get_keypress.__module__ = 'rads' def prompt_y_n(question: str) -> bool: """Prompt for a yes or no answer Args: question: text to display before [y/n] prompt Raises: SystemExit: if SIGINT is received """ valid = {"yes": True, "y": True, "no": False, "n": False} while True: print(question, '[y/n]') try: choice = input().lower() except KeyboardInterrupt: print("\nCancelled") sys.exit(1) if choice in valid: return valid[choice] print('Invalid answer. Try again:', color.bold('[y/n]')) prompt_y_n.__module__ = 'rads'