diff --git a/slpkg/arguments.py b/slpkg/arguments.py index a67f7a58..3c0846f6 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -225,8 +225,7 @@ def usage(repo, stderr): else: error_repo = (f"slpkg: Error: Repository '{repo}' does not exist" "\n") - print("\n" + error_repo) - raise SystemExit(1) + raise(f"\n {error_repo}") print(usage.__doc__) print("For more information try 'slpkg -h, --help' or view manpage\n") if stderr == 1: diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 5cc2143c..41580973 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -134,8 +134,7 @@ class BinaryInstall(BlackList, Utils): if self.matching and [""] != self.packages: print("\nMatching summary") print("=" * 79) - print(f"Total {sums[0]} matching packages\n") - raise SystemExit() + raise SystemExit(f"Total {sums[0]} matching packages\n") print("\nInstalling summary") print("=" * 79) print(f"{self.grey}Total {sums[0]} {self.msg.pkg(sums[0])}.") diff --git a/slpkg/graph.py b/slpkg/graph.py index 0c435270..671eda3a 100644 --- a/slpkg/graph.py +++ b/slpkg/graph.py @@ -57,9 +57,8 @@ class Graph: print("Require 'grap_easy': " "Install with 'slpkg -s sbo graph-easy'") else: - print("Require 'pygraphviz: " - "Install with 'slpkg -s sbo pygraphviz'") - raise SystemExit() + raise SystemExit("Require 'pygraphviz: " + "Install with 'slpkg -s sbo pygraphviz'") if self.image != "ascii": self.check_file() try: @@ -70,7 +69,7 @@ class Graph: self.graph_easy() G.draw(self.image) except IOError: - raise SystemExit() + raise SystemExit(1) if os.path.isfile(self.image): print(f"Graph image file '{self.image}' created") raise SystemExit() @@ -81,12 +80,11 @@ class Graph: try: image_type = f".{self.image.split('.')[1]}" if image_type not in self.file_format: - print(f"Format: '{self.image.split('.')[1]}' not recognized." - f" Use one of them:\n{', '.join(self.file_format)}") - raise SystemExit() + raise SystemExit(f"Format: '{self.image.split('.')[1]}' not " + f"recognized. Use one of them:\n" + f"{', '.join(self.file_format)}") except IndexError: - print("slpkg: Error: Image file suffix missing") - raise SystemExit() + raise SystemExit("slpkg: Error: Image file suffix missing") def graph_easy(self): """Draw ascii diagram. graph-easy perl module require @@ -95,10 +93,10 @@ class Graph: print("Require 'graph-easy': Install with 'slpkg -s sbo" " graph-easy'") self.remove_dot() - raise SystemExit() + raise SystemExit(1) subprocess.call(f"graph-easy {self.image}.dot", shell=True) self.remove_dot() - raise SystemExit() + raise SystemExit(1) def remove_dot(self): """Remove .dot files diff --git a/slpkg/health.py b/slpkg/health.py index ce314669..77fc5cc4 100644 --- a/slpkg/health.py +++ b/slpkg/health.py @@ -64,8 +64,7 @@ class PackageHealth: elif not self.mode: print(line) except IOError: - print() - raise SystemExit(1) + raise SystemExit("\n") def test(self): """Get started test each package and read file list diff --git a/slpkg/messages.py b/slpkg/messages.py index 836f5b06..ba487e5d 100644 --- a/slpkg/messages.py +++ b/slpkg/messages.py @@ -126,8 +126,7 @@ class Msg: try: answer = input("Would you like to continue [y/N]? ") except EOFError: - print() - raise SystemExit() + raise SystemExit("\n") return answer def security_pkg(self, pkg): diff --git a/slpkg/new_config.py b/slpkg/new_config.py index 074c94ba..2161a693 100644 --- a/slpkg/new_config.py +++ b/slpkg/new_config.py @@ -85,8 +85,7 @@ class NewConfig(Utils): try: choose = input("\nWhat would you like to do [K/O/R/P/Q]? ") except EOFError: - print() - raise SystemExit() + raise SystemExit("\n") print() if choose in ("K", "k"): self.keep() @@ -129,8 +128,7 @@ class NewConfig(Utils): self.question(self.news[self.i]) self.i += 1 except EOFError: - print() - raise SystemExit() + raise SystemExit("\n") def question(self, n): """Choose what do to file by file @@ -225,4 +223,4 @@ class NewConfig(Utils): n.split("/")[-1], n[:-4].split("/")[-1])) def quit(self): - raise SystemExit() \ No newline at end of file + raise SystemExit() diff --git a/slpkg/pkg/build.py b/slpkg/pkg/build.py index 411a4ff1..241e749a 100644 --- a/slpkg/pkg/build.py +++ b/slpkg/pkg/build.py @@ -76,8 +76,7 @@ class BuildPackage(Utils): try: tar = tarfile.open(self.script) except Exception as err: - print(err) - raise SystemExit() + raise SystemExit(err) tar.extractall() tar.close() self._makeflags() diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 0f65b8fb..d7ee25bc 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -54,14 +54,13 @@ class Repo(Utils): repo_name.append(line.split()[0]) if (repo in self.meta.repositories or repo in repo_name or repo in self.meta.default_repositories): - print(f"\nRepository name '{repo}' exist, select different name.\n" - "View all repositories with command 'slpkg " - "repo-list'.\n") - raise SystemExit(1) + raise SystemExit(f"\nRepository name '{repo}' exist, " + f"select different name.\n" + f"View all repositories with command 'slpkg " + f"repo-list'.\n") elif len(repo) > 6: - print("\nslpkg: Error: Maximum repository name length must be " - "six (6) characters\n") - raise SystemExit(1) + raise SystemExit("\nslpkg: Error: Maximum repository name length " + "must be six (6) characters\n") with open(self.custom_repo_file, "a") as repos: new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n" repos.write(new_line) @@ -103,10 +102,11 @@ class Repo(Utils): if line.split()[0] in self.DEFAULT_REPOS_NAMES: default_dict_repo[line.split()[0]] = line.split()[1] else: - print(f"\nslpkg: Error: Repository name '{line.split()[0]}'" - " is not default.\n Please check file: " - "/etc/slpkg/default-repositories\n") - raise SystemExit(1) + raise SystemExit(f"\nslpkg: Error: Repository name " + f"'{line.split()[0]}'" + f" is not default.\n " + f"Please check file: " + f"/etc/slpkg/default-repositories\n") return default_dict_repo def slack(self): diff --git a/slpkg/slpkg_update.py b/slpkg/slpkg_update.py index f80b8a9d..ccef7604 100644 --- a/slpkg/slpkg_update.py +++ b/slpkg/slpkg_update.py @@ -63,8 +63,7 @@ def it_self_update(): try: answer = input("Would you like to upgrade [y/N]? ") except EOFError: - print() - raise SystemExit(1) + raise SystemExit("\n") if answer in ["y", "Y"]: print() # new line after answer @@ -97,5 +96,5 @@ def it_self_update(): else: print(f"\n{_meta_.__all__}: There is no new version, " - "already used the last!\n") + "already you use the last!\n") raise SystemExit() diff --git a/slpkg/status_deps.py b/slpkg/status_deps.py index f06e032f..cf930ebd 100644 --- a/slpkg/status_deps.py +++ b/slpkg/status_deps.py @@ -118,10 +118,10 @@ class DependenciesStatus(Utils): def no_logs(self): """Print message if no logs found """ - print("\n There were no logs files. Obviously not used the\n" - " installation method with the command:\n" - " '$ slpkg -s ' yet.\n") - raise SystemExit() + raise SystemExit("\n There were no logs files. " + "Obviously not used the\n" + " installation method with the command:\n" + " '$ slpkg -s ' yet.\n") def summary(self): """Summary by packages and dependencies diff --git a/slpkg/superuser.py b/slpkg/superuser.py index cd04dbdf..123e3c38 100644 --- a/slpkg/superuser.py +++ b/slpkg/superuser.py @@ -30,13 +30,12 @@ def s_user(): """Check for root user """ if getpass.getuser() != "root": - print("\nslpkg: Error: Must have root privileges\n") - raise SystemExit(1) + raise SystemExit("\nslpkg: Error: Must have root privileges\n") def virtual_env(): """Check if a virtual enviroment exists """ if "VIRTUAL_ENV" in os.environ.keys(): - print("\nslpkg: Error: Please exit from virtual environment first\n") - raise SystemExit(1) + raise SystemExit("\nslpkg: Error: Please exit from virtual " + "environment first\n") diff --git a/slpkg/tracking.py b/slpkg/tracking.py index 7720e2ba..ca80e4c7 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -121,8 +121,7 @@ class TrackingDeps(BlackList, Utils): self.graph() else: self.msg.done() - print("\nNo package was found to match\n") - raise SystemExit(1) + raise SystemExit("\nNo package was found to match\n") def repositories(self): """Get dependencies by repositories