From 47acd0b822261b6b934f47b89b2276a686cc1865 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 15 Apr 2023 13:40:05 +0100 Subject: backend : improve the countdown timer, use it to kill the GUI whenever an unsupported operation is requested --- src/backend/upgrade.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/backend/upgrade.py') diff --git a/src/backend/upgrade.py b/src/backend/upgrade.py index 3f25ee7..8de534a 100644 --- a/src/backend/upgrade.py +++ b/src/backend/upgrade.py @@ -39,7 +39,7 @@ def start(ebuild=False, gfx_ui=False): bin_list, src_list, need_cfg = pickle.load( open(os.path.join(sisyphus.getfs.p_mtd_dir, "sisyphus_worlddeps.pickle"), "rb")) - if need_cfg != 0: # catch aliens + if need_cfg != 0: # catch aliens p_exe = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world']) try: @@ -55,6 +55,12 @@ def start(ebuild=False, gfx_ui=False): print("\nCannot proceed!\n") print( "Apply the above changes to your portage configuration files and try again") + + for i in range(9, 0, -1): + print(f"Killing application in : {i} seconds!") + time.sleep(1) + + sys.exit(app.exec_()) # kill GUI window else: print(sisyphus.getcolor.bright_red + "\nCannot proceed!\n" + sisyphus.getcolor.reset) @@ -71,7 +77,7 @@ def start(ebuild=False, gfx_ui=False): sys.exit() if ebuild: # ebuild mode - if len(bin_list) == 0 and len(src_list) != 0: # source only, ignore aliens + if len(bin_list) == 0 and len(src_list) != 0: # source mode, ignore aliens print("\n" + sisyphus.getcolor.green + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.green + ", ".join( src_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(src_list)) + " " + "source package(s)" + sisyphus.getcolor.reset + "\n") while True: @@ -97,7 +103,7 @@ def start(ebuild=False, gfx_ui=False): print("\nSorry, response" + " " + "'" + user_input + "'" + " " + "not understood.\n") continue - elif len(bin_list) != 0 and len(src_list) != 0: # binary and source, ignore aliens + elif len(bin_list) != 0 and len(src_list) != 0: # hybrid mode, ignore aliens print("\n" + sisyphus.getcolor.green + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.magenta + ", ".join( bin_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") print("\n" + sisyphus.getcolor.green + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.green + ", ".join( @@ -127,7 +133,7 @@ def start(ebuild=False, gfx_ui=False): print("\nSorry, response" + " " + "'" + user_input + "'" + " " + "not understood.\n") continue - elif len(bin_list) != 0 and len(src_list) == 0: # binary only, fallback + elif len(bin_list) != 0 and len(src_list) == 0: # binary mode, fallback print("\n" + sisyphus.getcolor.green + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.magenta + ", ".join( bin_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") while True: @@ -156,29 +162,41 @@ def start(ebuild=False, gfx_ui=False): user_input + "'" + " " + "not understood.\n") continue else: # non-ebuild mode - if len(bin_list) == 0 and len(src_list) != 0: # source only (noop), catch aliens + if len(bin_list) == 0 and len(src_list) != 0: # source mode (noop), catch aliens if gfx_ui: print("\nSource package(s) found in the mix!\n") print("Use sisyphus CLI:" + " " + "'" + "sisyphus upgrade --ebuild" + "'" + " " + "to perform the upgrade;" + " " + "Aborting.") + + for i in range(9, 0, -1): + print(f"Killing application in : {i} seconds!") + time.sleep(1) + + sys.exit(app.exec_()) # kill GUI window else: print(sisyphus.getcolor.bright_red + "\nSource package(s) found in the mix!\n" + sisyphus.getcolor.reset) print(sisyphus.getcolor.bright_yellow + "Use" + sisyphus.getcolor.reset + " " + "'" + "sisyphus upgrade --ebuild" + "'") sys.exit() - elif len(bin_list) != 0 and len(src_list) != 0: # binary and source (noop), catch aliens + elif len(bin_list) != 0 and len(src_list) != 0: # hybrid mode (noop), catch aliens if gfx_ui: print("\nSource package(s) found in the mix!\n") print("Use sisyphus CLI:" + " " + "'" + "sisyphus upgrade --ebuild" + "'" + " " + "to perform the upgrade;" + " " + "Aborting.") + + for i in range(9, 0, -1): + print(f"Killing application in : {i} seconds!") + time.sleep(1) + + sys.exit(app.exec_()) # kill GUI window else: print(sisyphus.getcolor.bright_red + "\nSource package(s) found in the mix!\n" + sisyphus.getcolor.reset) print(sisyphus.getcolor.bright_yellow + "Use" + sisyphus.getcolor.reset + " " + "'" + "sisyphus upgrade --ebuild" + "'") sys.exit() - elif len(bin_list) != 0 and len(src_list) == 0: # binary only + elif len(bin_list) != 0 and len(src_list) == 0: # binary mode if gfx_ui: print("\n" + "These are the binary packages that will be merged, in order:" + "\n\n" + ", ".join( bin_list) + "\n\n" + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + "\n\n") -- cgit v1.2.3