mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-05 11:02:14 +01:00
Merge print and raise
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
66aa4cf118
commit
1346f6e5b5
12 changed files with 38 additions and 50 deletions
|
@ -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:
|
||||
|
|
|
@ -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])}.")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
raise SystemExit()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 <repository> <packages>' 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 <repository> <packages>' yet.\n")
|
||||
|
||||
def summary(self):
|
||||
"""Summary by packages and dependencies
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue