diff options
Diffstat (limited to 'src/backend/pkgremove.py')
-rw-r--r-- | src/backend/pkgremove.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/backend/pkgremove.py b/src/backend/pkgremove.py index e9b36b8..eb60ad0 100644 --- a/src/backend/pkgremove.py +++ b/src/backend/pkgremove.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 import atexit +import colorama import fcntl import io import os @@ -11,11 +12,13 @@ import subprocess import sys import time import sisyphus.checkenv -import sisyphus.getclr import sisyphus.getfs import sisyphus.revdepsolve import sisyphus.syncdb import sisyphus.watchdog +from colorama import Fore, Back, Style + +colorama.init() def set_nonblocking(fd): @@ -49,7 +52,7 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): args = ['--quiet', '--depclean'] if not sisyphus.checkenv.root() and (unmerge or depclean): - print(f"{sisyphus.getclr.bright_red}\nRoot permissions are required to perform this action.\n{sisyphus.getclr.reset}") + print(f"{Fore.RED}{Style.BRIGHT}\nRoot permissions are required to perform this action.\n{Style.RESET_ALL}") sys.exit() else: if gfx_ui: @@ -144,8 +147,9 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): sys.exit() finally: p_exe.wait() - print(f"{sisyphus.getclr.bright_red}\nUnable to proceed! Other packages have dependencies preventing removal.{sisyphus.getclr.reset}") - print(f"{sisyphus.getclr.bright_white}Use the {sisyphus.getclr.reset}{sisyphus.getclr.green}'--force'{sisyphus.getclr.reset}{sisyphus.getclr.bright_white} option to override at your own risk!{sisyphus.getclr.reset}\n") + print( + f"{Fore.RED}{Style.BRIGHT}\nUnable to proceed! Other packages have dependencies preventing removal.{Style.RESET_ALL}") + print(f"{Fore.WHITE}{Style.BRIGHT}Use the {Style.RESET_ALL}{Fore.GREEN}'--force'{Style.RESET_ALL}{Fore.WHITE}{Style.BRIGHT} option to override at your own risk!{Style.RESET_ALL}\n") sys.exit() else: if is_installed == 0: @@ -158,22 +162,22 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): os.kill(os.getpid(), signal.SIGTERM) # kill GUI window else: - print(f"{sisyphus.getclr.bright_red}\nUnable to proceed! One or more selected packages could not be located for removal.\n{sisyphus.getclr.reset}") + print(f"{Fore.RED}{Style.BRIGHT}\nUnable to proceed! One or more selected packages could not be located for removal.\n{Style.RESET_ALL}") sys.exit() else: if unmerge: - print(f"\n{sisyphus.getclr.green}These are the selected packages that would be{sisyphus.getclr.reset} 'forcefully' {sisyphus.getclr.green}unmerged, in order:{sisyphus.getclr.reset}\n") + print(f"\n{Fore.GREEN}These are the selected packages that would be{Style.RESET_ALL} 'forcefully' {Fore.GREEN}unmerged, in order:{Style.RESET_ALL}\n") print( - f"\n{sisyphus.getclr.magenta}{', '.join(rm_list)}{sisyphus.getclr.reset}\n") + f"\n{Fore.MAGENTA}{', '.join(rm_list)}{Style.RESET_ALL}\n") print( - f"\n{sisyphus.getclr.bright_white}Total: {len(rm_list)} selected package(s){sisyphus.getclr.reset}\n") + f"\n{Fore.WHITE}{Style.BRIGHT}Total: {len(rm_list)} selected package(s){Style.RESET_ALL}\n") while True: user_input = input( - f"{sisyphus.getclr.bright_white}Would you like to proceed?{sisyphus.getclr.reset} [{sisyphus.getclr.bright_green}Yes{sisyphus.getclr.reset}/{sisyphus.getclr.bright_red}No{sisyphus.getclr.reset}] ") + f"{Fore.WHITE}{Style.BRIGHT}Would you like to proceed?{Style.RESET_ALL} [{Fore.GREEN}{Style.BRIGHT}Yes{Style.RESET_ALL}/{Fore.RED}{Style.BRIGHT}No{Style.RESET_ALL}] ") if user_input.lower() in ['yes', 'y', '']: while True: confirmation_input = input( - f"{sisyphus.getclr.bright_white}Are you sure you would like to proceed?{sisyphus.getclr.reset} [{sisyphus.getclr.bright_green}Yes{sisyphus.getclr.reset}/{sisyphus.getclr.bright_red}No{sisyphus.getclr.reset}] ") + f"{Fore.WHITE}{Style.BRIGHT}Are you sure you would like to proceed?{Style.RESET_ALL} [{Fore.GREEN}{Style.BRIGHT}Yes{Style.RESET_ALL}/{Fore.RED}{Style.BRIGHT}No{Style.RESET_ALL}] ") if confirmation_input.lower() in ['yes', 'y', '']: p_exe = subprocess.Popen( ['emerge', '--quiet', '--unmerge'] + list(pkgname)) @@ -231,15 +235,16 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): p_exe.wait() sisyphus.syncdb.lcl_tbl() else: - print(f"\n{sisyphus.getclr.green}These are the selected packages that would be{sisyphus.getclr.reset} 'safely' {sisyphus.getclr.green}unmerged, in order:{sisyphus.getclr.reset}\n") print( - f"\n{sisyphus.getclr.magenta}{', '.join(rm_list)}{sisyphus.getclr.reset}\n") + f"\n{Fore.GREEN}These are the selected packages that would be{Style.RESET_ALL} 'safely' {Fore.GREEN}unmerged, in order:{Style.RESET_ALL}\n") + print( + f"\n{Fore.MAGENTA}{', '.join(rm_list)}{Style.RESET_ALL}\n") print( - f"\n{sisyphus.getclr.bright_white}Total: {len(rm_list)} selected package(s){sisyphus.getclr.reset}\n") + f"\n{Fore.WHITE}{Style.BRIGHT}Total: {len(rm_list)} selected package(s){Style.RESET_ALL}\n") while True: user_input = input( - f"{sisyphus.getclr.bright_white}Would you like to proceed?{sisyphus.getclr.reset} [{sisyphus.getclr.bright_green}Yes{sisyphus.getclr.reset}/{sisyphus.getclr.bright_red}No{sisyphus.getclr.reset}] ") + f"{Fore.WHITE}{Style.BRIGHT}Would you like to proceed?{Style.RESET_ALL} [{Fore.GREEN}{Style.BRIGHT}Yes{Style.RESET_ALL}/{Fore.RED}{Style.BRIGHT}No{Style.RESET_ALL}] ") if user_input.lower() in ['yes', 'y', '']: p_exe = subprocess.Popen( ['emerge'] + args + list(pkgname)) |