30 lines
798 B
Python
30 lines
798 B
Python
# ssh_manager/utils.py
|
|
|
|
import sys
|
|
|
|
class Colors:
|
|
GREEN = "\033[0;32m"
|
|
RED = "\033[0;31m"
|
|
YELLOW = "\033[1;33m"
|
|
CYAN = "\033[0;36m"
|
|
BOLD = "\033[1m"
|
|
RESET = "\033[0m"
|
|
|
|
def print_error(message):
|
|
print(f"{Colors.RED}{Colors.BOLD}[✖] {Colors.RESET}{message}")
|
|
|
|
def print_warning(message):
|
|
print(f"{Colors.YELLOW}{Colors.BOLD}[⚠] {Colors.RESET}{message}")
|
|
|
|
def print_info(message):
|
|
print(f"{Colors.GREEN}{Colors.BOLD}[✔] {Colors.RESET}{message}")
|
|
|
|
def safe_input(prompt=""):
|
|
"""
|
|
A wrapper around input() that exits the entire script on Ctrl+C.
|
|
"""
|
|
try:
|
|
return input(prompt)
|
|
except KeyboardInterrupt:
|
|
print_info("\nExiting on Ctrl+C.")
|
|
sys.exit(130) # Conventionally 130 indicates "terminated by Ctrl+C"
|