Switch to raise the error

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-05-11 23:55:43 +03:00
parent 2e92d854e0
commit 66aa4cf118
6 changed files with 20 additions and 29 deletions

View file

@ -67,7 +67,7 @@ class PackageManager(Utils):
if os.path.isfile(self.meta.pkg_path + check): if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n") print("Completed!\n")
else: else:
raise SystemExit() raise SystemExit(1)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
self._not_found("Can't install", self.binary, pkg) self._not_found("Can't install", self.binary, pkg)
raise SystemExit(1) raise SystemExit(1)
@ -82,7 +82,7 @@ class PackageManager(Utils):
if os.path.isfile(self.meta.pkg_path + check): if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n") print("Completed!\n")
else: else:
raise SystemExit() raise SystemExit(1)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
self._not_found("Can't upgrade", self.binary, pkg) self._not_found("Can't upgrade", self.binary, pkg)
raise SystemExit(1) raise SystemExit(1)
@ -116,8 +116,7 @@ class PackageManager(Utils):
"\nAre you sure to remove {0} {1} [y/N]? ".format( "\nAre you sure to remove {0} {1} [y/N]? ".format(
str(len(self.removed)), msg)) str(len(self.removed)), msg))
except EOFError: except EOFError:
print() # new line at exit raise SystemExit(1)
raise SystemExit()
if remove_pkg in ["y", "Y"]: if remove_pkg in ["y", "Y"]:
self._check_if_used(self.binary) self._check_if_used(self.binary)
for rmv in self.removed: for rmv in self.removed:
@ -153,8 +152,7 @@ class PackageManager(Utils):
"other packages) [y/N]? ") "other packages) [y/N]? ")
print() print()
except EOFError: except EOFError:
print() # new line at exit raise SystemExit("\n")
raise SystemExit()
return remove_dep return remove_dep
def _get_removed(self): def _get_removed(self):
@ -296,8 +294,7 @@ class PackageManager(Utils):
if os.path.isfile(self.dep_path + package): if os.path.isfile(self.dep_path + package):
os.remove(self.dep_path + package) # remove log os.remove(self.dep_path + package) # remove log
except subprocess.CalledProcessError as er: except subprocess.CalledProcessError as er:
print(er) raise SystemExit(er)
raise SystemExit(1)
def _rmv_deps(self, dependencies, package): def _rmv_deps(self, dependencies, package):
"""Remove dependencies """Remove dependencies
@ -332,8 +329,7 @@ class PackageManager(Utils):
try: try:
self.skip = input(" > ").split() self.skip = input(" > ").split()
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit()
for s in self.skip: for s in self.skip:
if s in self.removed: if s in self.removed:
self.removed.remove(s) self.removed.remove(s)
@ -503,8 +499,7 @@ class PackageManager(Utils):
print(pkg) print(pkg)
print() # new line at end print() # new line at end
except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError): except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError):
print() # new line at exit raise SystemExit(1)
raise SystemExit()
def _splitting_packages(self, pkg, repo, name): def _splitting_packages(self, pkg, repo, name):
"""Return package name from repositories """Return package name from repositories

View file

@ -64,9 +64,9 @@ class AutoBuild:
"""Check if SlackBuild archive.tar.gz and sources exist """Check if SlackBuild archive.tar.gz and sources exist
""" """
if not os.path.isfile(self.path + self.script): if not os.path.isfile(self.path + self.script):
print("\nslpkg: Error: SlackBuild archive.tar.gz not found\n") raise SystemExit("\nslpkg: Error: SlackBuild archive.tar.gz "
raise SystemExit(1) "not found\n")
for src in self.sources: for src in self.sources:
if not os.path.isfile(self.path + src): if not os.path.isfile(self.path + src):
print(f"\nslpkg: Error: Source file '{src}' not found\n") raise SystemExit(f"\nslpkg: Error: Source file '{src}' "
raise SystemExit(1) f"not found\n")

View file

@ -172,8 +172,7 @@ class SBoNetwork(BlackList, Utils):
message = " Choose an option > " message = " Choose an option > "
self.choice = input(f"{self.grey}{message}{self.endc}") self.choice = input(f"{self.grey}{message}{self.endc}")
except EOFError: except EOFError:
print() raise SystemExit('\n')
raise SystemExit()
try: try:
print("{0}\x1b[1A{1}{2}{3}\n".format( print("{0}\x1b[1A{1}{2}{3}\n".format(
" " * len(message), self.cyan, commands[self.choice], " " * len(message), self.cyan, commands[self.choice],
@ -301,10 +300,9 @@ class SBoNetwork(BlackList, Utils):
status = False status = False
pkg = DialogUtil(data, text, title, backtitle, status).checklist() pkg = DialogUtil(data, text, title, backtitle, status).checklist()
if pkg and len(pkg) > 1: if pkg and len(pkg) > 1:
print("\nslpkg: Error: Choose only one package") raise SystemExit("\nslpkg: Error: Choose only one package")
raise SystemExit()
if pkg is None: if pkg is None:
raise SystemExit() raise SystemExit(1)
self.name = "".join(pkg) self.name = "".join(pkg)
os.system("clear") os.system("clear")

View file

@ -136,8 +136,8 @@ class QueuePkgs(Utils):
BuildPackage(script, sources, self.meta.build_path, BuildPackage(script, sources, self.meta.build_path,
auto=False).build() auto=False).build()
else: else:
print("\nPackages not found in the queue for building\n") raise SystemExit("\nPackages not found in the queue for "
raise SystemExit(1) "building\n")
def install(self): def install(self):
"""Install packages from queue """Install packages from queue
@ -155,5 +155,5 @@ class QueuePkgs(Utils):
print(f"\nPackage {prgnam} not found in the " print(f"\nPackage {prgnam} not found in the "
f"{self.meta.output} for installation\n") f"{self.meta.output} for installation\n")
else: else:
print("\nPackages not found in the queue for installation\n") raise SystemExit("\nPackages not found in the queue for "
raise SystemExit(1) "installation\n")

View file

@ -153,8 +153,7 @@ class SBoInstall(BlackList, Utils):
if self.match and [""] != self.slackbuilds: if self.match and [""] != self.slackbuilds:
print("\nMatching summary") print("\nMatching summary")
print("=" * 79) print("=" * 79)
print(f"Total {count_total} matching packages\n") raise SystemExit(f"Total {count_total} matching packages\n")
raise SystemExit(1)
print("\nInstalling summary") print("\nInstalling summary")
print("=" * 79) print("=" * 79)
print(f"{self.grey}Total {count_total} " print(f"{self.grey}Total {count_total} "

View file

@ -251,8 +251,7 @@ class Patches(BlackList, Utils):
answer = input("\nThe kernel has been upgraded, " answer = input("\nThe kernel has been upgraded, "
"reinstall boot loader [L/E/G]? ") "reinstall boot loader [L/E/G]? ")
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit()
if answer in ["L"]: if answer in ["L"]:
subprocess.call("lilo", shell=True) subprocess.call("lilo", shell=True)
break break