Updated code style

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2020-02-15 19:54:42 +01:00
parent 837dbe9de2
commit d264e8fe65
28 changed files with 147 additions and 141 deletions

View file

@ -1,6 +1,7 @@
3.8.2 - 15/02/2020
Fixed:
- SBo repository view Packages and New version
- msb repository PACKAGES.txt file
3.8.1 - 13/02/2020
Fixed:

View file

@ -38,7 +38,8 @@ from slpkg.binary.repo_init import RepoInit
def pkg_upgrade(repo, skip, flag):
"""Checking packages for upgrade
"""
Msg().checking()
msg = Msg()
msg.checking()
PACKAGES_TXT = RepoInit(repo).fetch()[0]
pkgs_for_upgrade = []
# name = data[0]
@ -57,7 +58,7 @@ def pkg_upgrade(repo, skip, flag):
inst_pkg[0] not in skip and
repo_pkg[1] != "blacklist"):
pkgs_for_upgrade.append(repo_pkg[0])
Msg().done()
msg.done()
if "--checklist" in flag:
pkgs_for_upgrade = choose_upg(pkgs_for_upgrade)
return pkgs_for_upgrade

View file

@ -30,6 +30,7 @@ from slpkg.__metadata__ import MetaData as _meta_
def check_md5(pkg_md5, src_file):
"""MD5 Checksum
"""
msg = Msg()
red = _meta_.color["RED"]
green = _meta_.color["GREEN"]
endc = _meta_.color["ENDC"]
@ -37,19 +38,19 @@ def check_md5(pkg_md5, src_file):
print()
md5s = md5(src_file)
if pkg_md5 != md5s:
Msg().template(78)
msg.template(78)
print(f"| MD5SUM check for {src_file.split('/')[-1]}"
f" [ {red}FAILED{endc} ]")
Msg().template(78)
msg.template(78)
print(f"| Expected: {pkg_md5}")
print(f"| Found: {md5s}")
Msg().template(78)
msg.template(78)
print()
if not Msg().answer() in ["y", "Y"]:
raise SystemExit()
else:
Msg().template(78)
msg.template(78)
print(f"| MD5SUM check for {src_file.split('/')[-1]}"
f" [ {green}PASSED{endc} ]")
Msg().template(78)
msg.template(78)
print() # new line after pass checksum

View file

@ -39,11 +39,10 @@ def clean_tmp():
# Delete a whole slpkg folder from the tmp directory
if os.path.exists(tmps[0]):
shutil.rmtree(tmps[0])
print("All packages and sources were deleted from: {0}".format(
tmps[0]))
print(f"All packages and sources were deleted from: {tmps[0]}")
# Recreate the paths again
if not os.path.exists(tmps[0]):
for tmp in tmps:
print("Created directory: {0}".format(tmp))
print(f"Created directory: {tmp}")
os.mkdir(tmp)
print("Done!")
print("Done!")

View file

@ -36,6 +36,7 @@ class Config:
def __init__(self):
self.config_file = "/etc/slpkg/slpkg.conf"
self.meta = _meta_
self.utils = Utils()
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
@ -66,11 +67,10 @@ class Config:
"DOWNDER_OPTIONS",
"SLACKPKG_LOG",
"ONLY_INSTALLED",
"PRG_BAR",
"EDITOR",
"NOT_DOWNGRADE"
]
read_conf = Utils().read_file(self.config_file)
read_conf = self.utils.read_file(self.config_file)
for line in read_conf.splitlines():
if not line.startswith("#") and line.split("=")[0] in conf_args:
print(line)
@ -89,4 +89,4 @@ class Config:
if filecmp.cmp(f"{self.config_file}.orig", self.config_file):
print(f"{self.green}The reset was done{self.endc}")
else:
print(f"{self.red}Reset failed{self.endc}")
print(f"{self.red}Reset failed{self.endc}")

View file

@ -38,6 +38,7 @@ class PkgDesc:
self.paint = paint
self.meta = _meta_
self.msg = Msg()
self.utils = Utils()
self.lib = ""
self.color = {
"red": self.meta.color["RED"],
@ -57,10 +58,10 @@ class PkgDesc:
if self.repo == "sbo":
description = SBoGrep(self.name).description()
else:
PACKAGES_TXT = Utils().read_file(self.lib)
PACKAGES_TXT = self.utils.read_file(self.lib)
for line in PACKAGES_TXT.splitlines():
if line.startswith(self.name + ":"):
description += line[len(self.name) + 2:] + "\n"
description += f"{line[len(self.name) + 2:]}\n"
count += 1
if count == 11:
break

View file

@ -31,11 +31,7 @@ class DialogUtil:
"""Create dialog checklist
"""
def __init__(self, *args):
try:
from dialog import Dialog
except ImportError:
raise SystemExit()
self.d = Dialog(dialog="dialog", autowidgetsize=True)
self.imp_dialog()
self.data = args[0]
self.text = args[1]
self.title = args[2]
@ -44,6 +40,13 @@ class DialogUtil:
self.ununicode = []
self.tags = []
def imp_dialog(self):
try:
from dialog import Dialog
except ImportError:
raise SystemExit()
self.d = Dialog(dialog="dialog", autowidgetsize=True)
def checklist(self):
"""Run dialog checklist
"""

View file

@ -78,8 +78,8 @@ 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. Use one of "
f"them:\n{', '.join(self.file_format)}")
print(f"Format: '{self.image.split('.')[1]}' not recognized."
f" Use one of them:\n{', '.join(self.file_format)}")
raise SystemExit()
except IndexError:
print("slpkg: Error: Image file suffix missing")
@ -89,8 +89,8 @@ class Graph:
"""Draw ascii diagram. graph-easy perl module require
"""
if not os.path.isfile("/usr/bin/graph-easy"):
print("Require 'graph-easy': Install with 'slpkg -s sbo "
"graph-easy'")
print("Require 'graph-easy': Install with 'slpkg -s sbo"
" graph-easy'")
self.remove_dot()
raise SystemExit()
subprocess.call(f"graph-easy {self.image}.dot", shell=True)

View file

@ -73,7 +73,7 @@ class PackageHealth:
self.packages()
self.cf = 0
for pkg in self.installed:
if os.path.isfile(self.meta.pkg_path + pkg):
if os.path.isfile(f"{self.meta.pkg_path}{pkg}"):
self.lf = 0
with open(self.pkg_path + pkg, "r") as fopen:
for line in fopen:

View file

@ -34,15 +34,18 @@ from slpkg.pkg.find import find_package
def library(repo):
"""Load packages from slpkg library and from local
"""
utils = Utils()
pkg_list, packages = [], ""
if repo == "sbo":
if (os.path.isfile(
f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")):
packages = Utils().read_file(f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")
packages = utils.read_file(
f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")
else:
if (os.path.isfile(
f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")):
packages = Utils().read_file(f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")
packages = utils.read_file(
f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")
for line in packages.splitlines():
if repo == "sbo":
if line.startswith("SLACKBUILD NAME: "):

View file

@ -34,13 +34,13 @@ def write_deps(deps_dict):
into directory `/var/log/slpkg/dep/`
"""
for name, dependencies in deps_dict.items():
if find_package(name + _meta_.sp, _meta_.pkg_path):
dep_path = _meta_.log_path + "dep/"
if find_package(f"{name}-", _meta_.pkg_path):
dep_path = f"{_meta_.log_path}dep/"
if not os.path.exists(dep_path):
os.mkdir(dep_path)
if os.path.isfile(dep_path + name):
os.remove(dep_path + name)
if os.path.isfile(f"{dep_path}{name}"):
os.remove(f"{dep_path}{name}")
if len(dependencies) >= 1:
with open(dep_path + name, "w") as f:
with open(f"{dep_path}{name}", "w") as f:
for dep in dependencies:
f.write(dep + "\n")
f.write(f"{dep}\n")

View file

@ -158,4 +158,4 @@ class Msg:
"""Message for matching packages
"""
print(f"\nNot found package with the name [ {self.cyan}{''.join(packages)}{self.endc} ]. "
f"Matching packages:\nNOTE: Not dependencies are resolved\n")
"Matching packages:\nNOTE: Not dependencies are resolved\n")

View file

@ -51,7 +51,7 @@ class NewConfig:
"""
self.find_new()
for n in self.news:
print(f"{n}")
print(n)
print()
self.msg.template(78)
print(f"| Installed {len(self.news)} new configuration files:")

View file

@ -34,7 +34,7 @@ def delete_package(path, packages):
"""
if _meta_.del_all in ["on", "ON"]:
for pkg in packages:
os.remove(path + pkg)
os.remove(f"{path}{pkg}")
def delete_folder(folder):

View file

@ -112,15 +112,15 @@ Keys: SPACE select or deselect the highlighted repositories,
if self.tag_line and line.startswith("#"):
repo = "".join(line.split("#")).strip()
if repo in self.selected:
new_conf.write(line.replace(line, repo + "\n"))
new_conf.write(line.replace(line, f"{repo}\n"))
continue
if (self.tag_line and not line.startswith("#") and
line != self.tag):
repo = line.strip()
if repo not in self.selected:
new_conf.write(line.replace(line, "# " + line + "\n"))
new_conf.write(line.replace(line, f"# {line}\n"))
continue
new_conf.write(line + "\n")
new_conf.write(f"{line}\n")
def clear_screen(self):
"""Clear screen

View file

@ -38,6 +38,8 @@ class RepoInfo:
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.repo = Repo()
self.utils = Utils()
self.form = {
"Last updated:": "",
"Number of packages:": "",
@ -49,9 +51,9 @@ class RepoInfo:
"Total uncompressed packages:": ""
}
self.meta = _meta_
self.all_repos = Repo().default_repository()
self.all_repos["slack"] = Repo().slack()
self.all_repos.update(Repo().custom_repository())
self.all_repos = self.repo.default_repository()
self.all_repos["slack"] = self.repo.slack()
self.all_repos.update(self.repo.custom_repository())
del RepoList().all_repos
def view(self, repo):
@ -66,7 +68,7 @@ class RepoInfo:
self.form["Default:"] = "yes"
if (repo in self.meta.repositories and
os.path.isfile(self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):
os.path.isfile(f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT")):
status = f"{self.green}enabled{self.endc}"
if repo != "sbo":
@ -81,19 +83,20 @@ class RepoInfo:
self.form["Number of packages:"] = data[0]
self.form["Status:"] = status
self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile(
self.meta.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")):
f"{self.meta.lib_path}{repo}_repo/SLACKBUILDS.TXT")):
status = f"{self.green}enabled{self.endc}"
sum_sbo_pkgs = 0
for line in (Utils().read_file(
self.meta.lib_path + "sbo_repo/SLACKBUILDS."
for line in (self.utils.read_file(
f"{self.meta.lib_path}sbo_repo/SLACKBUILDS."
"TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1
changelog_txt = Utils().read_file(
self.meta.log_path + "sbo/ChangeLog.txt")
changelog_txt = self.utils.read_file(
f"{self.meta.log_path}sbo/ChangeLog.txt")
last_upd = changelog_txt.split("\n", 1)[0]
self.form["Repo id:"] = repo
@ -108,13 +111,12 @@ class RepoInfo:
print(f"{self.green}{key}{self.endc} {value}")
def repository_data(self, repo):
"""
Grap data packages
"""Grap data packages
"""
sum_pkgs, size, unsize, last_upd = 0, [], [], ""
f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT"
for line in Utils().read_file(f).splitlines():
for line in self.utils.read_file(f).splitlines():
if line.startswith("PACKAGES.TXT;"):
last_upd = line[14:].strip()
if line.startswith("PACKAGE NAME:"):
@ -125,8 +127,8 @@ class RepoInfo:
unsize.append(line[30:-2].strip())
if repo in ["salix", "slackl"]:
log = Utils().read_file(
self.meta.log_path + f"{repo}/ChangeLog.txt")
log = self.utils.read_file(
f"{self.meta.log_path}{repo}/ChangeLog.txt")
last_upd = log.split("\n", 1)[0]
return [sum_pkgs, size, unsize, last_upd]

View file

@ -47,27 +47,25 @@ class Repo:
"""
repo_name = []
if not url.endswith("/"):
url = url + "/"
url += "/"
for line in self.custom_repositories_list.splitlines():
line = line.lstrip()
if line and not line.startswith("#"):
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("\nRepository name '{0}' exist, select different name.\n"
print(f"\nRepository name '{repo}' exist, select different name.\n"
"View all repositories with command 'slpkg "
"repo-list'.\n".format(repo))
raise SystemExit()
"repo-list'.\n")
raise SystemExit(1)
elif len(repo) > 6:
print("\nslpkg: Error: Maximum repository name length must be "
"six (6) characters\n")
raise SystemExit()
raise SystemExit(1)
with open(self.custom_repo_file, "a") as repos:
new_line = " {0}{1}{2}\n".format(repo, " " * (10 - len(repo)),
url)
new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n"
repos.write(new_line)
print("\nRepository '{0}' successfully added\n".format(repo))
raise SystemExit()
print(f"\nRepository '{repo}' successfully added\n")
def remove(self, repo):
"""Remove custom repository
@ -77,14 +75,13 @@ class Repo:
for line in self.custom_repositories_list.splitlines():
repo_name = line.split()[0]
if repo_name != repo:
repos.write(line + "\n")
repos.write(f"{line}\n")
else:
print("\nRepository '{0}' successfully "
"removed\n".format(repo))
print(f"\nRepository '{repo}' successfully "
"removed\n")
rem_repo = True
if not rem_repo:
print("\nRepository '{0}' doesn't exist\n".format(repo))
raise SystemExit()
print(f"\nRepository '{repo}' doesn't exist\n")
def custom_repository(self):
"""Return dictionary with repo name and url (used external)
@ -106,11 +103,10 @@ class Repo:
if line.split()[0] in self.DEFAULT_REPOS_NAMES:
default_dict_repo[line.split()[0]] = line.split()[1]
else:
print("\nslpkg: Error: Repository name '{0}' is not "
"default.\n Please check file: "
"/etc/slpkg/default-repositories\n".format(
line.split()[0]))
raise SystemExit()
print(f"\nslpkg: Error: Repository name '{line.split()[0]}'"
" is not default.\n Please check file: "
"/etc/slpkg/default-repositories\n")
raise SystemExit(1)
return default_dict_repo
def slack(self):
@ -121,11 +117,11 @@ class Repo:
default = "http://ftp.arm.slackware.com/slackwarearm/"
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
mirrors = Utils().read_file(
self.meta.conf_path + "slackware-mirrors")
f"{self.meta.conf_path}slackware-mirrors")
for line in mirrors.splitlines():
line = line.rstrip()
if not line.startswith("#") and line:
default = line.split()[-1]
if not default.endswith("/"):
default += "/"
return default
return default

View file

@ -29,7 +29,6 @@ class SBoLink:
self.sbo_url = sbo_url
def tar_gz(self):
"""Return link slackbuild tar.gz archive
"""
Return link slackbuild tar.gz archive
"""
return (self.sbo_url[:-1] + ".tar.gz")
return f"{self.sbo_url[:-1]}.tar.gz"

View file

@ -30,9 +30,10 @@ from slpkg.slack.slack_version import slack_ver
def sbo_search_pkg(name):
"""Search for package path from SLACKBUILDS.TXT file and
"""Search for package path in SLACKBUILDS.TXT file and
return url
"""
url = ""
repo = Repo().default_repository()["sbo"]
sbo_url = f"{repo}{slack_ver()}/"
SLACKBUILDS_TXT = Utils().read_file(
@ -41,5 +42,5 @@ def sbo_search_pkg(name):
if line.startswith("SLACKBUILD LOCATION"):
sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip()
if name == sbo_name:
return (sbo_url + line[23:].strip() + "/")
return ""
url = f"{sbo_url}{line[23:].strip()}/"
return url

View file

@ -62,6 +62,7 @@ class SBoInstall:
self.grey = _meta_.color["GREY"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.utils = Utils()
self.arch = SBoArch().get()
self.build_folder = self.meta.build_path
self._SOURCES = self.meta.SBo_SOURCES
@ -172,7 +173,7 @@ class SBoInstall:
lowercase
"""
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.data)
data_dict = self.utils.case_sensitive(self.data)
for name in self.slackbuilds:
index = self.slackbuilds.index(name)
for key, value in data_dict.items():
@ -182,10 +183,9 @@ class SBoInstall:
def update_deps(self):
"""Update dependencies dictionary with all package
"""
utils = Utils()
onelist, dependencies = [], []
onelist = utils.dimensional_list(self.deps)
dependencies = utils.remove_dbs(onelist)
onelist = self.utils.dimensional_list(self.deps)
dependencies = self.utils.remove_dbs(onelist)
for dep in dependencies:
deps = Requires(self.flag).sbo(dep)
self.deps_dict[dep] = self.one_for_all(deps)
@ -213,7 +213,7 @@ class SBoInstall:
"""Clear master slackbuilds if already exist in dependencies
or if added to install two or more times
"""
self.master_packages = Utils().remove_dbs(self.master_packages)
self.master_packages = self.utils.remove_dbs(self.master_packages)
for mas in self.master_packages:
if mas in self.dependencies:
self.master_packages.remove(mas)
@ -246,8 +246,8 @@ class SBoInstall:
deps.reverse()
# Inverting the list brings the
# dependencies in order to be installed.
requires = Utils().dimensional_list(deps)
dependencies = Utils().remove_dbs(requires)
requires = self.utils.dimensional_list(deps)
dependencies = self.utils.remove_dbs(requires)
return dependencies
def top_view(self):

View file

@ -30,7 +30,7 @@ def pkg_security(pkgs):
"""Check packages before install or upgrade for security
reasons. Configuration file in the /etc/slpkg/pkg_security"""
security_packages = Utils().read_file("/etc/slpkg/pkg_security")
packages = []
packages, msg = [], Msg()
for read in security_packages.splitlines():
read = read.lstrip()
if not read.startswith("#"):
@ -38,6 +38,6 @@ def pkg_security(pkgs):
for p in pkgs:
for pkg in packages:
if p == pkg:
Msg().security_pkg(p)
if not Msg().answer() in ["y", "Y"]:
msg.security_pkg(p)
if not msg.answer() in ["y", "Y"]:
raise SystemExit()

View file

@ -29,9 +29,8 @@ from slpkg.slack.slack_version import slack_ver
def mirrors(name, location):
"""
Select Slackware official mirror packages
based architecture and version.
"""Select Slackware official mirror packages
based architecture and version.
"""
rel = _meta_.slack_rel
ver = slack_ver()

View file

@ -83,8 +83,7 @@ class Patches:
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading()
def start(self):
"""
Install new patches from official Slackware mirrors
"""Install new patches from official Slackware mirrors
"""
self.store()
self.msg.done()
@ -131,8 +130,7 @@ class Patches:
f" distribution is up to date!\n")
def store(self):
"""
Store and return packages for upgrading
"""Store and return packages for upgrading
"""
data = repo_data(self.PACKAGES_TXT, "slack", self.flag)
black = BlackList().get_black()
@ -179,8 +177,7 @@ class Patches:
raise SystemExit()
def views(self):
"""
Views packages
"""Views packages
"""
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
pkg_repo = split_package(upg[:-4])
@ -196,8 +193,7 @@ class Patches:
f"{' ' * (7-len(pkg_repo[3]))}Slack{size:>12} K")
def upgrade(self):
"""
Upgrade packages
"""Upgrade packages
"""
for pkg in self.upgrade_all:
check_md5(pkg_checksum(pkg, "slack_patches"),
@ -216,8 +212,7 @@ class Patches:
self.installed.append(pkg_ver)
def kernel(self):
"""
Check if kernel upgraded if true
"""Check if kernel upgraded if true
then reinstall "lilo"
"""
for core in self.upgrade_all:
@ -253,13 +248,13 @@ class Patches:
from Slackware official mirrors after update distribution.
"""
NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading()
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt.old"):
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt.old")
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt"):
shutil.copy2(self.meta.slackpkg_lib_path + "ChangeLog.txt",
self.meta.slackpkg_lib_path + "ChangeLog.txt.old")
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt")
with open(self.meta.slackpkg_lib_path + "ChangeLog.txt", "w") as log:
if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old"):
os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt"):
shutil.copy2(f"{self.meta.slackpkg_lib_path}ChangeLog.txt",
f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt")
with open(f"{self.meta.slackpkg_lib_path}ChangeLog.txt", "w") as log:
log.write(NEW_ChangeLog_txt)
def update_lists(self):
@ -269,4 +264,4 @@ class Patches:
print(f"{self.green}Update the package lists ?{self.endc}")
print("=" * 79)
if self.msg.answer() in ["y", "Y"]:
Update().repository(["slack"])
Update().run(["slack"])

View file

@ -31,12 +31,11 @@ from slpkg.__metadata__ import MetaData as _meta_
def slackware_repository():
"""Return all official Slackware packages
"""
slack_repo, packages, names, name = [], [], [], ""
slack_repo, packages, names = [], [], []
slack_repo = repo_data(
Utils().read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"),
"slack", "")
for pkg in slack_repo[0]:
name = split_package(pkg)[0]
names.append(name)
names.append(split_package(pkg)[0])
packages.append(pkg[:-4])
return packages, names
return packages, names

View file

@ -62,7 +62,7 @@ def it_self_update():
answer = input("Would you like to upgrade [y/N]? ")
except EOFError:
print()
raise SystemExit()
raise SystemExit(1)
if answer in ["y", "Y"]:
print() # new line after answer
else:
@ -78,17 +78,16 @@ def it_self_update():
os.makedirs(_meta_.build_path)
Download(_meta_.build_path, dwn_link, repo="").start()
os.chdir(_meta_.build_path)
slpkg_tar_file = "slpkg" + "-" + __new_version__ + ".tar.gz"
slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz"
tar = tarfile.open(slpkg_tar_file)
tar.extractall()
tar.close()
file_name = "{0}-{1}".format(_meta_.__all__, __new_version__)
file_name = f"{_meta_.__all__}-{__new_version__}"
os.chdir(file_name)
check_md5(pkg_checksum(slpkg_tar_file, _meta_.__all__),
_meta_.build_path + slpkg_tar_file)
subprocess.call("chmod +x {0}".format("install.sh"), shell=True)
subprocess.call("sh install.sh", shell=True)
else:
print("\n{0}: There is no new version, already used the last!"
"\n".format(_meta_.__all__))
raise SystemExit()
print(f"\n{_meta_.__all__}: There is no new version, already used the last!")
raise SystemExit()

View file

@ -40,6 +40,7 @@ class DependenciesStatus:
self.image = image
self.meta = _meta_
self.msg = Msg()
self.utils = Utils()
self.grey = self.meta.color["GREY"]
self.green = self.meta.color["GREEN"]
self.endc = self.meta.color["ENDC"]
@ -57,10 +58,10 @@ class DependenciesStatus:
dictionary database
"""
for pkg in self.installed:
if os.path.isfile(self.meta.pkg_path + pkg):
if os.path.isfile(f"{self.meta.pkg_path}{pkg}"):
name = split_package(pkg)[0]
for log in self.logs:
deps = Utils().read_file(self.dep_path + log)
deps = self.utils.read_file(f"{self.dep_path}{log}")
for dep in deps.splitlines():
if name == dep:
if name not in self.dmap.keys():
@ -86,7 +87,7 @@ class DependenciesStatus:
self.data()
print()
self.msg.template(78)
print("| {0}{1}{2}".format("Dependencies", " " * 20, "Packages"))
print(f"| Dependencies{' ' * 20}Packages")
self.msg.template(78)
for key, value in self.dmap.items():
print(" {0}{1}{2}{3}{4}".format(
@ -105,12 +106,12 @@ class DependenciesStatus:
self.msg.template(78)
self.data()
for pkg, dep in self.dmap.items():
print("+ {0}{1}{2}".format(self.green, pkg, self.endc))
print(f"+ {self.green}{pkg}{self.endc}")
print("|")
for d in dep:
print("+-- {0}".format(d))
print(f"+-- {d}")
print("|")
print("\x1b[1A{0}\n".format(" "), end="", flush=True)
print("\x1b[1A \n", end="", flush=True)
self.summary()
if self.image:
Graph(self.image).dependencies(self.dmap)

View file

@ -30,4 +30,4 @@ def s_user():
"""
if getpass.getuser() != "root":
print("\nslpkg: Error: Must have root privileges\n")
raise SystemExit()
raise SystemExit(1)

View file

@ -50,6 +50,7 @@ class TrackingDeps:
self.flag = flag
self.meta = _meta_
self.msg = Msg()
self.utils = Utils()
self.green = self.meta.color["GREEN"]
self.yellow = self.meta.color["YELLOW"]
self.cyan = self.meta.color["CYAN"]
@ -59,6 +60,11 @@ class TrackingDeps:
self.dependencies = []
self.dependencies_list = []
self.deps_dict = {}
self.init_flags()
def init_flags(self):
"""Flags initialization
"""
for i in range(0, len(self.flag)):
if self.flag[i].startswith("--graph="):
self.image = self.flag[i].split("=")[1]
@ -71,8 +77,8 @@ class TrackingDeps:
self.repositories()
if self.find_pkg:
self.dependencies_list.reverse()
self.requires = Utils().dimensional_list(self.dependencies_list)
self.dependencies = Utils().remove_dbs(self.requires)
self.requires = self.utils.dimensional_list(self.dependencies_list)
self.dependencies = self.utils.remove_dbs(self.requires)
if self.dependencies == []:
self.dependencies = ["No dependencies"]
if "--graph=" in self.flag:
@ -123,9 +129,9 @@ class TrackingDeps:
if self.find_pkg:
self.dependencies_list = Requires(self.flag).sbo(self.name)
else:
PACKAGES_TXT = Utils().read_file(
self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT")
self.names = list(Utils().package_name(PACKAGES_TXT))
PACKAGES_TXT = self.utils.read_file(
f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT")
self.names = list(self.utils.package_name(PACKAGES_TXT))
self.bin_case_insensitive()
self.find_pkg = search_pkg(self.name, self.repo)
if self.find_pkg:
@ -139,7 +145,7 @@ class TrackingDeps:
"""
if "--case-ins" in self.flag:
data = SBoGrep(name="").names()
data_dict = Utils().case_sensitive(data)
data_dict = self.utils.case_sensitive(data)
for key, value in data_dict.items():
if key == self.name.lower():
self.name = value
@ -149,7 +155,7 @@ class TrackingDeps:
lowercase
"""
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.names)
data_dict = self.utils.case_sensitive(self.names)
for key, value in data_dict.items():
if key == self.name.lower():
self.name = value
@ -163,10 +169,10 @@ class TrackingDeps:
"""Check if dependencies used
"""
used = []
dep_path = self.meta.log_path + "dep/"
dep_path = f"{self.meta.log_path}dep/"
logs = find_package("", dep_path)
for log in logs:
deps = Utils().read_file(dep_path + log)
deps = self.utils.read_file(f"{dep_path}{log}")
for dep in deps.splitlines():
if pkg == dep:
used.append(log)
@ -180,17 +186,17 @@ class TrackingDeps:
for dep in dependencies:
deps = Requires(flag="").sbo(dep)
if dep not in self.deps_dict.values():
self.deps_dict[dep] = Utils().dimensional_list(deps)
self.deps_dict[dep] = self.utils.dimensional_list(deps)
else:
for dep in dependencies:
deps = Dependencies(self.repo, self.black).binary(dep, flag="")
if dep not in self.deps_dict.values():
self.deps_dict[dep] = Utils().dimensional_list(deps)
self.deps_dict[dep] = self.utils.dimensional_list(deps)
def deps_used(self, pkg, used):
"""Create dependencies dictionary
"""
if find_package(pkg + self.meta.sp, self.meta.pkg_path):
if find_package(f"{pkg}-", self.meta.pkg_path):
if pkg not in self.deps_dict.values():
self.deps_dict[pkg] = used
else: