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