summaryrefslogtreecommitdiff
path: root/src/backend/sysupgrade.py
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-03-01 11:37:04 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-03-01 11:37:04 +0000
commitd81c5e5ffd727a4a0e00910b93eb17737d8f8193 (patch)
tree2d18957c3954948c0db6a4a70c0c1a41197c1564 /src/backend/sysupgrade.py
parent5a8384b21bb066ca44f6823871ad1d0aa1aa2c28 (diff)
rewrite the print statements in a more concise and professional wayv6.2403.0
Diffstat (limited to 'src/backend/sysupgrade.py')
-rw-r--r--src/backend/sysupgrade.py143
1 files changed, 68 insertions, 75 deletions
diff --git a/src/backend/sysupgrade.py b/src/backend/sysupgrade.py
index f85b2a6..f6415f3 100644
--- a/src/backend/sysupgrade.py
+++ b/src/backend/sysupgrade.py
@@ -49,8 +49,7 @@ signal.signal(signal.SIGINT, sigint_handler)
def start(ebuild=False, gfx_ui=False):
if not sisyphus.checkenv.root():
- print(sisyphus.getclr.bright_red +
- "\nYou need root permissions to do this!\n" + sisyphus.getclr.reset)
+ print(f"{sisyphus.getclr.bright_red}\nRoot permissions are required for this operation.\n{sisyphus.getclr.reset}")
sys.exit()
else:
if gfx_ui:
@@ -75,41 +74,35 @@ def start(ebuild=False, gfx_ui=False):
p_exe.kill()
sys.exit()
if gfx_ui:
- print("\nCannot proceed!\n")
- print(
- "Apply the above changes to your portage configuration files and try again")
-
+ print("\nCannot proceed!\nPlease 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.getclr.bright_red +
- "\nCannot proceed!\n" + sisyphus.getclr.reset)
- print(sisyphus.getclr.bright_yellow +
- "Apply the above changes to your portage configuration files and try again" + sisyphus.getclr.reset)
+ print(f"{sisyphus.getclr.bright_red}\nCannot proceed!\n{sisyphus.getclr.reset}{sisyphus.getclr.bright_yellow}Please apply the above changes to your portage configuration files and try again!{sisyphus.getclr.reset}")
sys.exit()
else:
if len(bin_list) == 0 and len(src_list) == 0:
if gfx_ui:
- print("\nNo package upgrades found!\n")
+ print("\nThe system is up to date; no package upgrades are required.\n")
else:
- print(sisyphus.getclr.bright_red +
- "\nNo package upgrades found!\n" + sisyphus.getclr.reset)
+ print(
+ f"{sisyphus.getclr.bright_red}\nThe system is up to date; no package upgrades are required.\n{sisyphus.getclr.reset}")
sys.exit()
if ebuild: # ebuild mode
if len(bin_list) == 0 and len(src_list) != 0: # source mode, ignore aliens
- print("\n" + sisyphus.getclr.green +
- "These are the source packages that would be merged, in order:" + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.green +
- ", ".join(src_list) + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.bright_white + "Total:" + " " + str(
- len(src_list)) + " " + "source package(s)" + sisyphus.getclr.reset + "\n")
+ print(
+ f"\n{sisyphus.getclr.green}These are the source packages that would be merged, in order:{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.green}{', '.join(src_list)}{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.bright_white}Total: {len(src_list)} source package(s){sisyphus.getclr.reset}\n")
while True:
- user_input = input(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 + "]" + " ")
+ 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}] ")
if user_input.lower() in ['yes', 'y', '']:
p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse',
'--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'])
@@ -143,26 +136,26 @@ def start(ebuild=False, gfx_ui=False):
elif user_input.lower() in ['no', 'n']:
break
else:
- print("\nSorry, response" + " " + "'" +
- user_input + "'" + " " + "not understood.\n")
+ print(
+ f"\nApologies, the response '{user_input}' was not recognized.\n")
continue
elif len(bin_list) != 0 and len(src_list) != 0: # hybrid mode, ignore aliens
- print("\n" + sisyphus.getclr.green +
- "These are the binary packages that would be merged, in order:" + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.magenta +
- ", ".join(bin_list) + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.bright_white + "Total:" + " " + str(
- len(bin_list)) + " " + "binary package(s)" + sisyphus.getclr.reset + "\n")
-
- print("\n" + sisyphus.getclr.green +
- "These are the source packages that would be merged, in order:" + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.green +
- ", ".join(src_list) + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.bright_white + "Total:" + " " + str(
- len(src_list)) + " " + "source package(s)" + sisyphus.getclr.reset + "\n")
+ print(
+ f"\n{sisyphus.getclr.green}These are the binary packages that would be merged, in order:{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.magenta}{', '.join(bin_list)}{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.bright_white}Total: {len(bin_list)} binary package(s){sisyphus.getclr.reset}\n")
+
+ print(
+ f"\n{sisyphus.getclr.green}These are the source packages that would be merged, in order:{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.green}{', '.join(src_list)}{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.bright_white}Total: {len(src_list)} source package(s){sisyphus.getclr.reset}\n")
while True:
- user_input = input(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 + "]" + " ")
+ 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}] ")
if user_input.lower() in ['yes', 'y', '']:
sisyphus.dlbinpkg.start(dl_world=True, gfx_ui=False)
os.chdir(sisyphus.getfs.p_cch_dir)
@@ -198,19 +191,19 @@ def start(ebuild=False, gfx_ui=False):
elif user_input.lower() in ['no', 'n']:
break
else:
- print("\nSorry, response" + " " + "'" +
- user_input + "'" + " " + "not understood.\n")
+ print(
+ f"\nApologies, the response '{user_input}' was not recognized.\n")
continue
elif len(bin_list) != 0 and len(src_list) == 0: # binary mode, fallback
- print("\n" + sisyphus.getclr.green +
- "These are the binary packages that would be merged, in order:" + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.magenta +
- ", ".join(bin_list) + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.bright_white + "Total:" + " " + str(
- len(bin_list)) + " " + "binary package(s)" + sisyphus.getclr.reset + "\n")
+ print(
+ f"\n{sisyphus.getclr.green}These are the binary packages that would be merged, in order:{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.magenta}{', '.join(bin_list)}{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.bright_white}Total: {len(bin_list)} binary package(s){sisyphus.getclr.reset}\n")
while True:
- user_input = input(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 + "]" + " ")
+ 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}] ")
if user_input.lower() in ['yes', 'y', '']:
sisyphus.dlbinpkg.start(dl_world=True, gfx_ui=False)
os.chdir(sisyphus.getfs.p_cch_dir)
@@ -246,15 +239,15 @@ def start(ebuild=False, gfx_ui=False):
elif user_input.lower() in ['no', 'n']:
break
else:
- print("\nSorry, response" + " " + "'" +
- user_input + "'" + " " + "not understood.\n")
+ print(
+ f"\nApologies, the response '{user_input}' was not recognized.\n")
continue
else: # non-ebuild mode
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.")
+ print(
+ f"Use the Sisyphus CLI command: 'sisyphus upgrade --ebuild' to perform the upgrade; Aborting.")
for i in range(9, 0, -1):
print(f"Killing application in : {i} seconds!")
@@ -262,16 +255,16 @@ def start(ebuild=False, gfx_ui=False):
sys.exit(app.exec_()) # kill GUI window
else:
- print(sisyphus.getclr.bright_red +
- "\nSource package(s) found in the mix!\n" + sisyphus.getclr.reset)
- print(sisyphus.getclr.bright_yellow + "Use" +
- sisyphus.getclr.reset + " " + "'" + "sisyphus upgrade --ebuild" + "'")
+ print(
+ f"{sisyphus.getclr.bright_red}\nSource package(s) found in the mix!{sisyphus.getclr.reset}")
+ print(
+ f"{sisyphus.getclr.bright_yellow}Use{sisyphus.getclr.reset} 'sisyphus upgrade --ebuild' to perform the upgrade; Aborting.")
sys.exit()
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.")
+ print(
+ f"Use the Sisyphus CLI command: 'sisyphus upgrade --ebuild' to perform the upgrade; Aborting.")
for i in range(9, 0, -1):
print(f"Killing application in : {i} seconds!")
@@ -279,17 +272,17 @@ def start(ebuild=False, gfx_ui=False):
sys.exit(app.exec_()) # kill GUI window
else:
- print(sisyphus.getclr.bright_red +
- "\nSource package(s) found in the mix!\n" + sisyphus.getclr.reset)
- print(sisyphus.getclr.bright_yellow + "Use" +
- sisyphus.getclr.reset + " " + "'" + "sisyphus upgrade --ebuild" + "'")
+ print(
+ f"{sisyphus.getclr.bright_red}\nSource package(s) found in the mix!{sisyphus.getclr.reset}")
+ print(
+ f"{sisyphus.getclr.bright_yellow}Use{sisyphus.getclr.reset} 'sisyphus upgrade --ebuild' to perform the upgrade; Aborting.")
sys.exit()
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")
- print("\n" + ", ".join(bin_list) + "\n\n" + "Total:" + " " +
- str(len(bin_list)) + " " + "binary package(s)" + "\n\n")
+ f"\nThese are the binary packages that will be merged, in order:\n")
+ print(", ".join(bin_list) +
+ f"\n\nTotal: {len(bin_list)} binary package(s)\n")
sisyphus.dlbinpkg.start(dl_world=True, gfx_ui=True)
os.chdir(sisyphus.getfs.p_cch_dir)
p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries',
@@ -303,15 +296,15 @@ def start(ebuild=False, gfx_ui=False):
p_exe.wait()
sisyphus.syncdb.lcl_tbl()
else:
- print("\n" + sisyphus.getclr.green +
- "These are the binary packages that would be merged, in order:" + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.magenta +
- ", ".join(bin_list) + sisyphus.getclr.reset + "\n")
- print("\n" + sisyphus.getclr.bright_white + "Total:" + " " + str(
- len(bin_list)) + " " + "binary package(s)" + sisyphus.getclr.reset + "\n")
+ print(
+ f"\n{sisyphus.getclr.green}These are the binary packages that would be merged, in order:{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.magenta}{', '.join(bin_list)}{sisyphus.getclr.reset}\n")
+ print(
+ f"\n{sisyphus.getclr.bright_white}Total: {len(bin_list)} binary package(s){sisyphus.getclr.reset}\n")
while True:
- user_input = input(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 + "]" + " ")
+ 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}] ")
if user_input.lower() in ['yes', 'y', '']:
sisyphus.dlbinpkg.start(
dl_world=True, gfx_ui=False)
@@ -348,6 +341,6 @@ def start(ebuild=False, gfx_ui=False):
elif user_input.lower() in ['no', 'n']:
break
else:
- print("\nSorry, response" + " " + "'" +
- user_input + "'" + " " + "not understood.\n")
+ print(
+ f"\nApologies, the response '{user_input}' was not recognized.\n")
continue