added additional functions
This commit is contained in:
parent
1e55abf811
commit
67a5534246
8 changed files with 654 additions and 107 deletions
12
utils.py
12
utils.py
|
@ -1,5 +1,7 @@
|
|||
# ssh_manager/utils.py
|
||||
|
||||
import sys
|
||||
|
||||
class Colors:
|
||||
GREEN = "\033[0;32m"
|
||||
RED = "\033[0;31m"
|
||||
|
@ -16,3 +18,13 @@ def print_warning(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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue