diff --git a/.gitignore b/.gitignore
index 38df1be4..2450cb8a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
*.pyc
__pycache__
.pipy
+.idea
*.egg-info/
/slpkg_Build
.ropeproject/
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 584f5a56..4116600a 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,4 +1,14 @@
-3.9.5 - 02/04/2022
+3.9.7 - 09/05/2022
+Fixed:
+- Stderr error output
+Updated:
+- Improve dependencies resolve speed
+- Renamed --repositories to --repos flag
+Bugfix:
+- Update custom repositories
+- Passing repositories manual
+
+3.9.6 - 02/04/2022
Updated:
- Compared packages version when distribution upgrade
diff --git a/README.md b/README.md
index 9a5573ee..d3efcf67 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# slpkg 3.9.6
+# slpkg 3.9.7
Slpkg is a powerful software package manager that installs, updates, and removes packages on
[Slackware](http://www.slackware.com/) based systems. It automatically computes dependencies and
diff --git a/man/slpkg.8 b/man/slpkg.8
index 69a224ed..be37a854 100644
--- a/man/slpkg.8
+++ b/man/slpkg.8
@@ -11,7 +11,7 @@
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
-.TH Slpkg "14" "01" 2019" "slpkg"
+.TH Slpkg "11" "05" 2022" "slpkg"
.SH NAME
Slpkg is a user-friendly package manager for Slackware installations
.SH SYNOPSIS
@@ -34,24 +34,24 @@ Print the version of program and exit.
The following commands are available.
.SS update, create and update packages list
-\fBslpkg\fP \fBupdate\fP, \fB--repositories=[repositories...]\fP
+\fBslpkg\fP \fBupdate\fP, \fB--repos=[repositories...]\fP
.PP
Used to re-synchronize the package lists and create some important files.
This command must run every new repository is added or new updates is available.
.PP
Additional options:
.PP
-\fB--repositories=[repositories...]\fP : Update at specifically repositories separate by comma.
+\fB--repos=[repositories...]\fP : Update at specifically repositories separate by comma.
.SS upgrade, recreate packages list
-\fBslpkg\fP \fBupgrade\fP, \fB--repositories=[repositories...]\fP
+\fBslpkg\fP \fBupgrade\fP, \fB--repos=[repositories...]\fP
.PP
It is sometimes useful to create all of the base file from the beginning so this
command delete all the package lists and recreated.
.PP
Additional options:
.PP
-\fB--repositories=[repositories...]\fP : Update at specifically repositories separate by comma.
+\fB--repos=[repositories...]\fP : Update at specifically repositories separate by comma.
.SS repo-add, add custom repository
\fBslpkg\fP \fBrepo-add\fP <\fIrepository name\fP> <\fIURL\fP>
@@ -404,7 +404,7 @@ Dimitris Zlatanidis
.SH HOMEPAGE
https://dslackw.gitlab.io/slpkg/
.SH COPYRIGHT
-Copyright \(co 2014-2019 Dimitris Zlatanidis
+Copyright \(co 2014-2022 Dimitris Zlatanidis
.SH SEE ALSO
installpkg(8), upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8), explodepkg(8),
diff --git a/man/slpkg.html b/man/slpkg.html
index 8b76d2fa..57d26c63 100644
--- a/man/slpkg.html
+++ b/man/slpkg.html
@@ -1,5 +1,5 @@
-
+
@@ -93,7 +93,7 @@ commands are available.
update,
create and update packages list
slpkg update,
---repositories=[repositories...]
+--repos=[repositories...]
Used to
re-synchronize the package lists and create some important
@@ -104,13 +104,13 @@ or new updates is available.
options:
---repositories=[repositories...]
+
--repos=[repositories...]
: Update at specifically repositories separate by comma.
upgrade,
recreate packages list
slpkg upgrade,
---repositories=[repositories...]
+--repos=[repositories...]
It is sometimes
useful to create all of the base file from the beginning so
@@ -120,7 +120,7 @@ this command delete all the package lists and recreated.
options:
---repositories=[repositories...]
+
--repos=[repositories...]
: Update at specifically repositories separate by comma.
repo-add,
@@ -728,7 +728,7 @@ Zlatanidis <d.zlatanidis@gmail.com>
Copyright
-© 2014-2019 Dimitris Zlatanidis
+© 2014-2022 Dimitris Zlatanidis
SEE ALSO
diff --git a/pytest.ini b/pytest.ini
deleted file mode 100644
index c085b4c5..00000000
--- a/pytest.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[pytest]
-python_files = test_*
-python_classes = *Tests
-python_functions = test_*
diff --git a/requirements.txt b/requirements.txt
index 74db8801..9fb8bd88 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,4 +11,3 @@
# perl 5 language and graph-easy >= 0.75 (drawing dependencies ascii diagram)
# python3-pythondialog >= 3.5.0 (Python interface to the UNIX dialog utility)
# flake8 >= 3.5.0
-# pytest >= 5.3.2
diff --git a/setup.py b/setup.py
index 445e1ccb..40e068d0 100755
--- a/setup.py
+++ b/setup.py
@@ -32,9 +32,7 @@ except ImportError:
from distutils.core import setup
docs_requires = []
-tests_requires = [
- "pytest>=5.3.2"
-]
+tests_requires = []
install_requires = []
optional_requires = [
"pythondialog>=3.5.1",
diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py
index 0c11ee7c..3ba3f081 100644
--- a/slpkg/__metadata__.py
+++ b/slpkg/__metadata__.py
@@ -25,6 +25,11 @@
import os
+# Slackware distribution branches
+STABLE = "stable"
+CURRENT = "current"
+
+
def remove_repositories(repositories, default_repositories):
"""
Remove no default repositories
@@ -67,7 +72,7 @@ def select_slack_release(slack_rel):
Warning message if Slackware release not defined or
defined wrong
"""
- if slack_rel not in ["stable", "current"]:
+ if slack_rel not in [STABLE, CURRENT]:
return "FAULT"
return slack_rel
@@ -76,7 +81,7 @@ class MetaData:
__all__ = "slpkg"
__author__ = "dslackw"
- __version_info__ = (3, 9, 6)
+ __version_info__ = (3, 9, 7)
__version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com"
@@ -84,7 +89,7 @@ class MetaData:
__homepage__ = "https://dslackw.gitlab.io/slpkg/"
# Default Slackware release
- slack_rel = "stable"
+ slack_rel = STABLE
# Configuration path
conf_path = f"/etc/{__all__}/"
@@ -95,7 +100,7 @@ class MetaData:
# Default configuration values
_conf_slpkg = {
- "RELEASE": "stable",
+ "RELEASE": STABLE,
"SLACKWARE_VERSION": "off",
"COMP_ARCH": "off",
"REPOSITORIES": ["slack", "sbo", "rlw", "alien",
diff --git a/slpkg/arguments.py b/slpkg/arguments.py
index a69218c6..3c0846f6 100644
--- a/slpkg/arguments.py
+++ b/slpkg/arguments.py
@@ -48,10 +48,10 @@ Usage: slpkg [COMMANDS|OPTIONS] {repository|package...}
_Slackware package manager_______
Commands:
- update, --repositories=[...] Run this command to update all
+ update, --repos=[...] Run this command to update all
the packages lists.
- upgrade, --repositories=[...] Delete and recreate all packages
+ upgrade, --repos=[...] Delete and recreate all packages
lists.
repo-add [repository name] [URL] Add custom repository.
@@ -171,12 +171,12 @@ Homepage: https://dslackw.gitlab.io/slpkg/
print(options.__doc__)
-def usage(repo):
+def usage(repo, stderr):
"""Usage: slpkg [COMMANDS|OPTIONS] {repository|package...}
Commands:
- [update, --repositories=[...]]
- [upgrade, --repositories=[...]]
+ [update, --repos=[...]]
+ [upgrade, --repos=[...]]
[repo-add [repository name] [URL]]
[repo-remove [repository]]
[repo-enable]
@@ -225,7 +225,8 @@ def usage(repo):
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:
+ raise SystemExit(stderr)
diff --git a/slpkg/auto_pkg.py b/slpkg/auto_pkg.py
index dbbcb9e7..cf2c884a 100644
--- a/slpkg/auto_pkg.py
+++ b/slpkg/auto_pkg.py
@@ -55,7 +55,8 @@ class Auto:
print("| Choose a Slackware command:")
self.msg.template(78)
for com in sorted(self.commands):
- print(f"| {self.red}{com}{self.endc}) {self.green}{self.commands[com]}{self.endc}")
+ print(f"| {self.red}{com}{self.endc}) {self.green}"
+ f"{self.commands[com]}{self.endc}")
self.msg.template(78)
try:
self.choice = input(" > ")
@@ -63,7 +64,8 @@ class Auto:
print()
raise SystemExit()
if self.choice in self.commands.keys():
- print(f" \x1b[1A{self.cyan}{self.commands[self.choice]}{self.endc}", end="\n\n")
+ print(f" \x1b[1A{self.cyan}{self.commands[self.choice]}"
+ f"{self.endc}", end="\n\n")
print(end="", flush=True)
self.execute()
diff --git a/slpkg/binary/dependency.py b/slpkg/binary/dependency.py
index 1f179af0..f22416b6 100644
--- a/slpkg/binary/dependency.py
+++ b/slpkg/binary/dependency.py
@@ -23,6 +23,7 @@
import sys
+from functools import lru_cache
from slpkg.__metadata__ import MetaData as _meta_
@@ -49,11 +50,12 @@ class Dependencies:
for req in requires:
if req and req not in self.black:
dependencies.append(req)
- self.deep_check(dependencies, flag)
+ self.deep_check(tuple(dependencies), tuple(flag))
return self.dep_results
else:
return []
+ @lru_cache
def deep_check(self, dependencies, flag):
"""Checking if dependencies are finnished
"""
diff --git a/slpkg/binary/greps.py b/slpkg/binary/greps.py
index c58664c4..b1404e78 100644
--- a/slpkg/binary/greps.py
+++ b/slpkg/binary/greps.py
@@ -22,6 +22,7 @@
# along with this program. If not, see .
+from functools import lru_cache
from slpkg.utils import Utils
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_
@@ -193,7 +194,8 @@ class Requires:
else:
return ""
else:
- PACKAGES_TXT = Utils().read_file(f"{_meta_.lib_path}{self.repo}_repo/PACKAGES.TXT")
+ PACKAGES_TXT = Utils().read_file(f"{_meta_.lib_path}"
+ f"{self.repo}_repo/PACKAGES.TXT")
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"):
pkg_name = split_package(line[14:].strip())[0]
@@ -202,9 +204,10 @@ class Requires:
if line[18:].strip():
return self._req_fix(line)
+ @lru_cache
def _req_fix(self, line):
- """Fix slacky and salix requirements because many dependencies splitting
- with "," and others with "|"
+ """Fix slacky and salix requirements because many dependencies
+ splitting with "," and others with "|"
"""
deps = []
for dep in line[18:].strip().split(","):
diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py
index 9ffd79f8..41580973 100644
--- a/slpkg/binary/install.py
+++ b/slpkg/binary/install.py
@@ -134,16 +134,16 @@ 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(1)
+ 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])}.")
- print(f"{sums[3]} {self.msg.pkg(sums[3])} will be installed, {sums[2]} will be upgraded and "
+ print(f"{sums[3]} {self.msg.pkg(sums[3])} will be installed, "
+ f"{sums[2]} will be upgraded and "
f"{sums[1]} will be reinstalled.")
print(f"Need to get {size[0]} {unit[0]} of archives.")
- print(f"After this process, {size[1]} {unit[1]} of additional disk "
- f"space will be used.{self.endc}")
+ print(f"After this process, {size[1]} {unit[1]} of additional "
+ f"disk space will be used.{self.endc}")
print()
self.if_all_installed()
if self.msg.answer() in ["y", "Y"]:
@@ -314,7 +314,8 @@ class BinaryInstall(BlackList, Utils):
"""Print packages status bar
"""
self.msg.template(78)
- print(f"| Package{' ' * 17}New Version{' ' * 8}Arch{' ' * 4}Build{' ' * 2}Repos{' ' * 10}Size")
+ print(f"| Package{' ' * 17}New Version{' ' * 8}Arch{' ' * 4}"
+ f"Build{' ' * 2}Repos{' ' * 10}Size")
self.msg.template(78)
def store(self, packages):
diff --git a/slpkg/binary/repo_init.py b/slpkg/binary/repo_init.py
index 1e15ac0e..241615c8 100644
--- a/slpkg/binary/repo_init.py
+++ b/slpkg/binary/repo_init.py
@@ -102,7 +102,8 @@ class RepoInit(Utils):
if self.meta.arch == "x86_64":
arch = "64"
self.mirror = (f"{self.def_repo_dict['slacke']}"
- f"slacke{self.meta.slacke_sub_repo[1:-1]}/slackware{arch}-{slack_ver()}/")
+ f"slacke{self.meta.slacke_sub_repo[1:-1]}/slackware"
+ f"{arch}-{slack_ver()}/")
def _init_salix(self):
arch = "i486"
@@ -123,7 +124,8 @@ class RepoInit(Utils):
arch = "x86"
if self.meta.arch == "x86_64":
arch = "x86_64"
- self.mirror = f"{self.def_repo_dict['msb']}{slack_ver()}/{self.meta.msb_sub_repo[1:-1]}/{arch}/"
+ self.mirror = (f"{self.def_repo_dict['msb']}{slack_ver()}/"
+ f"{self.meta.msb_sub_repo[1:-1]}/{arch}/")
def _init_csb(self):
arch = "x86"
@@ -135,10 +137,13 @@ class RepoInit(Utils):
arch = ""
if self.meta.arch == "x86_64":
arch = "64"
- self.mirror = f"{self.def_repo_dict['connos']}slack-n-free{arch}-{slack_ver()}/"
+ self.mirror = (f"{self.def_repo_dict['connos']}slack-n-free"
+ f"{arch}-{slack_ver()}/")
def _init_mles(self):
arch = "32"
if self.meta.arch == "x86_64":
arch = "64"
- self.mirror = f"{self.def_repo_dict['mles']}{self.meta.mles_sub_repo[1:-1]}-{slack_ver()}-{arch}bit/"
+ self.mirror = (f"{self.def_repo_dict['mles']}"
+ f"{self.meta.mles_sub_repo[1:-1]}-"
+ f"{slack_ver()}-{arch}bit/")
diff --git a/slpkg/checks.py b/slpkg/checks.py
index 71cd862d..3b475eb8 100644
--- a/slpkg/checks.py
+++ b/slpkg/checks.py
@@ -35,7 +35,6 @@ class Updates:
self.repo = repo
self.meta = _meta_
self.green = _meta_.color["GREEN"]
- self.grey = _meta_.color["GREY"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.check = 2
@@ -78,13 +77,11 @@ class Updates:
try:
self.check = self.all_repos[self.repo]()
except OSError:
- usage(self.repo)
- raise SystemExit()
+ usage(self.repo, 1)
elif self.repo in self.meta.repositories:
self.check = self._init.custom(self.repo)
else:
- usage(self.repo)
- raise SystemExit()
+ usage(self.repo, 1)
self.status_bar()
self.status()
self.print_status(self.repo)
@@ -99,8 +96,7 @@ class Updates:
try:
self.check = self.all_repos[repo]()
except OSError:
- usage(self.repo)
- raise SystemExit()
+ usage(self.repo, 1)
elif repo in self.meta.repositories:
self.check = self._init.custom(repo)
self.status()
@@ -132,5 +128,5 @@ class Updates:
cmd = "Repository is updated."
if self.count_news > 0:
cmd = "Run the command 'slpkg update'."
- print(f"{self.grey}From {self.count_repo} repositories need"
- f" {self.count_news} updating. {cmd}{self.endc}", end="\n")
+ print(f"From {self.count_repo} repositories need"
+ f" {self.count_news} updating. {cmd}", end="\n")
diff --git a/slpkg/graph.py b/slpkg/graph.py
index d819558e..671eda3a 100644
--- a/slpkg/graph.py
+++ b/slpkg/graph.py
@@ -52,11 +52,13 @@ class Graph:
try:
import pygraphviz as pgv
except ImportError:
- if self.image == "ascii" and not os.path.isfile("/usr/bin/graph-easy"):
- print("Require 'grap_easy': Install with 'slpkg -s sbo graph-easy'")
+ if (self.image == "ascii"
+ and not os.path.isfile("/usr/bin/graph-easy")):
+ 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:
@@ -67,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()
@@ -78,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
@@ -92,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/grep_md5.py b/slpkg/grep_md5.py
index 9f387b30..f701a83f 100644
--- a/slpkg/grep_md5.py
+++ b/slpkg/grep_md5.py
@@ -33,11 +33,11 @@ def pkg_checksum(binary, repo):
"""
md5 = "None"
if repo == "slack_patches" and _meta_.slack_rel == "stable":
- CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).reading()
+ CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).get_request()
elif repo == "slack_patches" and _meta_.slack_rel == "current":
- CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).reading()
+ CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).get_request()
elif repo == "slpkg":
- CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).reading()
+ CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).get_request()
else:
lib = f"{_meta_.lib_path}{repo}_repo/CHECKSUMS.md5"
f = open(lib, "r")
diff --git a/slpkg/health.py b/slpkg/health.py
index a1356931..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()
+ raise SystemExit("\n")
def test(self):
"""Get started test each package and read file list
@@ -102,4 +101,4 @@ class PackageHealth:
print(f"| Total files{' ' * 7}Not installed{' ' * 40}Health")
self.msg.template(78)
print(f"| {self.cf}{' ' * (18-len(str(self.cf)))}{self.cn}{' ' * (55-len(str(self.cn)))}{health:>4}")
- self.msg.template(78)
\ No newline at end of file
+ self.msg.template(78)
diff --git a/slpkg/init.py b/slpkg/init.py
index 572c5243..fc6666ba 100644
--- a/slpkg/init.py
+++ b/slpkg/init.py
@@ -42,6 +42,8 @@ class Initialization(Utils):
def __init__(self, check):
self.check = check
self.meta = _meta_
+ self.arch = _meta_.arch
+ self.slack_ver = slack_ver()
self.def_repos_dict = Repo().default_repository()
self.conf_path = self.meta.conf_path
self.log_path = self.meta.log_path
@@ -56,22 +58,32 @@ class Initialization(Utils):
def constructing(self):
"""Creating the all necessary directories
"""
- if not os.path.exists(self.conf_path):
- os.mkdir(self.conf_path)
- if not os.path.exists(self.log_path):
- os.mkdir(self.log_path)
- if not os.path.exists(self.lib_path):
- os.mkdir(self.lib_path)
- if not os.path.exists(self.tmp_path):
- os.mkdir(self.tmp_path)
- if not os.path.exists(self.build_path):
- os.makedirs(self.build_path)
- if not os.path.exists(self._SOURCES):
- os.makedirs(self._SOURCES)
- if not os.path.exists(self.slpkg_tmp_packages):
- os.makedirs(self.slpkg_tmp_packages)
- if not os.path.exists(self.slpkg_tmp_patches):
- os.makedirs(self.slpkg_tmp_patches)
+ paths_basic = [
+ self.conf_path,
+ self.log_path,
+ self.lib_path,
+ self.tmp_path
+ ]
+
+ paths_extra = [
+ self.build_path,
+ self._SOURCES,
+ self.slpkg_tmp_packages,
+ self.slpkg_tmp_patches
+ ]
+
+ self.make_dir(paths_basic)
+ self.make_dirs(paths_extra)
+
+ def make_dir(self, path: list):
+ for p in path:
+ if not os.path.exists(p):
+ os.mkdir(p)
+
+ def make_dirs(self, path: list):
+ for p in path:
+ if not os.path.exists(p):
+ os.makedirs(p)
def custom(self, name):
"""Creating user select repository local library
@@ -84,10 +96,7 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
+ self.make_dir([log, lib])
PACKAGES_TXT = f"{repo}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}"
@@ -110,14 +119,11 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
dirs = ["core/", "extra/", "patches/"]
- for d in dirs:
- if not os.path.exists(lib + d):
- os.mkdir(lib + d)
+ self.make_dir([log, lib])
+ self.make_dir([f"{lib}{dirs[0]}",
+ f"{lib}{dirs[1]}",
+ f"{lib}{dirs[2]}"])
PACKAGES_TXT = mirrors(lib_file, "")
FILELIST_TXT = ""
CHECKSUMS_MD5 = mirrors(md5_file, "")
@@ -155,14 +161,11 @@ class Initialization(Utils):
# lst_file = ""
# md5_file = ""
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- SLACKBUILDS_TXT = f"{repo}{slack_ver()}/{lib_file}"
+ self.make_dir([log, lib])
+ SLACKBUILDS_TXT = f"{repo}{self.slack_ver}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = ""
- ChangeLog_txt = f"{repo}{slack_ver()}/{log_file}"
+ ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, SLACKBUILDS_TXT, repo_name)
@@ -181,14 +184,11 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- PACKAGES_TXT = f"{repo}{slack_ver()}/{lib_file}"
+ self.make_dir([log, lib])
+ PACKAGES_TXT = f"{repo}{self.slack_ver}/{lib_file}"
FILELIST_TXT = ""
- CHECKSUMS_MD5 = f"{repo}{slack_ver()}/{md5_file}"
- ChangeLog_txt = f"{repo}{slack_ver()}/{log_file}"
+ CHECKSUMS_MD5 = f"{repo}{self.slack_ver}/{md5_file}"
+ ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@@ -201,8 +201,7 @@ class Initialization(Utils):
"""Creating alien local library
"""
ar = "x86"
- ver = slack_ver()
- arch = self.meta.arch
+ ver = self.slack_ver
repo = self.def_repos_dict["alien"]
log = self.log_path + "alien/"
lib = self.lib_path + "alien_repo/"
@@ -211,12 +210,9 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
- ar = arch
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
+ ar = self.arch
if self.meta.slack_rel == "current":
ver = self.meta.slack_rel
PACKAGES_TXT = f"{repo}/{ver}/{ar}/{lib_file}"
@@ -235,7 +231,6 @@ class Initialization(Utils):
"""Creating slacky.eu local library
"""
ar = ""
- arch = self.meta.arch
repo = self.def_repos_dict["slacky"]
log = self.log_path + "slacky/"
lib = self.lib_path + "slacky_repo/"
@@ -244,17 +239,14 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "64"
- PACKAGES_TXT = f"{repo}slackware{ar}-{slack_ver()}/{lib_file}"
+ PACKAGES_TXT = f"{repo}slackware{ar}-{self.slack_ver}/{lib_file}"
FILELIST_TXT = ""
- CHECKSUMS_MD5 = f"{repo}slackware{ar}-{slack_ver()}/{md5_file}"
+ CHECKSUMS_MD5 = f"{repo}slackware{ar}-{self.slack_ver}/{md5_file}"
- ChangeLog_txt = f"{repo}slackware{ar}-{slack_ver()}/{log_file}"
+ ChangeLog_txt = f"{repo}slackware{ar}-{self.slack_ver}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@@ -274,10 +266,7 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
+ self.make_dir([log, lib])
PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}"
@@ -293,9 +282,7 @@ class Initialization(Utils):
def slonly(self):
"""Creating slackers local library
"""
- ver = slack_ver()
- ar = f"{ver}-x86"
- arch = self.meta.arch
+ ar = f"{self.slack_ver}-x86"
repo = self.def_repos_dict["slonly"]
log = self.log_path + "slonly/"
lib = self.lib_path + "slonly_repo/"
@@ -304,15 +291,12 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
- ar = f"{ver}-x86_64"
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
+ ar = f"{self.slack_ver}-x86_64"
if self.meta.slack_rel == "current":
ar = f"{self.meta.slack_rel}-x86"
- if self.meta.slack_rel == "current" and arch == "x86_64":
+ if self.meta.slack_rel == "current" and self.arch == "x86_64":
ar = f"{self.meta.slack_rel}-x86_64"
PACKAGES_TXT = f"{repo}{ar}/{lib_file}"
FILELIST_TXT = ""
@@ -337,10 +321,7 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
+ self.make_dir([log, lib])
PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}"
@@ -356,7 +337,7 @@ class Initialization(Utils):
def multi(self):
"""Creating alien multilib local library
"""
- ver = slack_ver()
+ ver = self.slack_ver
repo = self.def_repos_dict["multi"]
log = self.log_path + "multi/"
lib = self.lib_path + "multi_repo/"
@@ -365,10 +346,7 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
+ self.make_dir([log, lib])
if self.meta.slack_rel == "current":
ver = self.meta.slack_rel
PACKAGES_TXT = f"{repo}{ver}/{lib_file}"
@@ -387,7 +365,6 @@ class Initialization(Utils):
"""Creating Slacke local library
"""
ar = ""
- arch = self.meta.arch
repo = self.def_repos_dict["slacke"]
log = self.log_path + "slacke/"
lib = self.lib_path + "slacke_repo/"
@@ -396,17 +373,17 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "64"
version = self.meta.slacke_sub_repo[1:-1]
- PACKAGES_TXT = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{lib_file}"
+ PACKAGES_TXT = (f"{repo}slacke{version}/slackware{ar}-"
+ f"{self.slack_ver}/{lib_file}")
FILELIST_TXT = ""
- CHECKSUMS_MD5 = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{md5_file}"
- ChangeLog_txt = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{log_file}"
+ CHECKSUMS_MD5 = (f"{repo}slacke{version}/slackware{ar}-"
+ f"{self.slack_ver}/{md5_file}")
+ ChangeLog_txt = (f"{repo}slacke{version}/slackware{ar}-"
+ f"{self.slack_ver}/{log_file}")
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@@ -419,7 +396,6 @@ class Initialization(Utils):
"""Creating SalixOS local library
"""
ar = "i486"
- arch = self.meta.arch
repo = self.def_repos_dict["salix"]
log = self.log_path + "salix/"
lib = self.lib_path + "salix_repo/"
@@ -428,16 +404,13 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "x86_64"
- PACKAGES_TXT = f"{repo}{ar}/{slack_ver()}/{lib_file}"
+ PACKAGES_TXT = f"{repo}{ar}/{self.slack_ver}/{lib_file}"
FILELIST_TXT = ""
- CHECKSUMS_MD5 = f"{repo}{ar}/{slack_ver()}/{md5_file}"
- ChangeLog_txt = f"{repo}{ar}/{slack_ver()}/{log_file}"
+ CHECKSUMS_MD5 = f"{repo}{ar}/{self.slack_ver}/{md5_file}"
+ ChangeLog_txt = f"{repo}{ar}/{self.slack_ver}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@@ -450,7 +423,6 @@ class Initialization(Utils):
"""Creating slackel.gr local library
"""
ar = "i486"
- arch = self.meta.arch
repo = self.def_repos_dict["slackl"]
log = self.log_path + "slackl/"
lib = self.lib_path + "slackl_repo/"
@@ -459,11 +431,8 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "x86_64"
PACKAGES_TXT = f"{repo}{ar}/current/{lib_file}"
FILELIST_TXT = ""
@@ -488,10 +457,7 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
+ self.make_dir([log, lib])
PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}"
@@ -508,8 +474,7 @@ class Initialization(Utils):
"""Creating MATE local library
"""
ar = "x86"
- ver_slack = slack_ver()
- arch = self.meta.arch
+ ver_slack = self.slack_ver
repo = self.def_repos_dict["msb"]
log = self.log_path + "msb/"
lib = self.lib_path + "msb_repo/"
@@ -518,11 +483,8 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "x86_64"
version = self.meta.msb_sub_repo[1:-1]
if self.meta.slack_rel == "current":
@@ -543,8 +505,7 @@ class Initialization(Utils):
"""Creating Cinnamon local library
"""
ar = "x86"
- ver_slack = slack_ver()
- arch = self.meta.arch
+ ver_slack = self.slack_ver
repo = self.def_repos_dict["csb"]
log = self.log_path + "csb/"
lib = self.lib_path + "csb_repo/"
@@ -553,11 +514,8 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "x86_64"
if self.meta.slack_rel == "current":
ver_slack = self.meta.slack_rel
@@ -578,7 +536,6 @@ class Initialization(Utils):
"""
nickname = "slack-n-free"
ar = ""
- arch = self.meta.arch
repo = self.def_repos_dict["connos"]
log = self.log_path + "connos/"
lib = self.lib_path + "connos_repo/"
@@ -587,16 +544,13 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "64"
- PACKAGES_TXT = f"{repo}{nickname}{ar}-{slack_ver()}/{lib_file}"
+ PACKAGES_TXT = f"{repo}{nickname}{ar}-{self.slack_ver}/{lib_file}"
FILELIST_TXT = ""
- CHECKSUMS_MD5 = f"{repo}{nickname}{ar}-{slack_ver()}/{md5_file}"
- ChangeLog_txt = f"{repo}{nickname}{ar}-{slack_ver()}/{log_file}"
+ CHECKSUMS_MD5 = f"{repo}{nickname}{ar}-{self.slack_ver}/{md5_file}"
+ ChangeLog_txt = f"{repo}{nickname}{ar}-{self.slack_ver}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@@ -609,7 +563,6 @@ class Initialization(Utils):
"""Creating Microlinux local library
"""
ar = "32"
- arch = self.meta.arch
repo = self.def_repos_dict["mles"]
log = self.log_path + "mles/"
lib = self.lib_path + "mles_repo/"
@@ -618,17 +571,14 @@ class Initialization(Utils):
# lst_file = ""
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
- if not os.path.exists(log):
- os.mkdir(log)
- if not os.path.exists(lib):
- os.mkdir(lib)
- if arch == "x86_64":
+ self.make_dir([log, lib])
+ if self.arch == "x86_64":
ar = "64"
version = self.meta.mles_sub_repo[1:-1]
- PACKAGES_TXT = f"{repo}{version}-{slack_ver()}-{ar}bit/{lib_file}"
+ PACKAGES_TXT = f"{repo}{version}-{self.slack_ver}-{ar}bit/{lib_file}"
FILELIST_TXT = ""
- CHECKSUMS_MD5 = f"{repo}{version}-{slack_ver()}-{ar}bit/{md5_file}"
- ChangeLog_txt = f"{repo}{version}-{slack_ver()}-{ar}bit/{log_file}"
+ CHECKSUMS_MD5 = f"{repo}{version}-{self.slack_ver}-{ar}bit/{md5_file}"
+ ChangeLog_txt = f"{repo}{version}-{self.slack_ver}-{ar}bit/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@@ -746,10 +696,11 @@ class Update:
def __init__(self):
self.meta = _meta_
self.grey = _meta_.color["GREY"]
+ self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
self.endc = _meta_.color["ENDC"]
- self.done = f"{self.grey}Done{self.endc}\n"
+ self.done = f"{self.green}Done{self.endc}\n"
self.error = f"{self.red}Error{self.endc}\n"
def run(self, repos):
@@ -758,6 +709,7 @@ class Update:
print("\nCheck and update repositories:\n")
default = self.meta.default_repositories
enabled = self.meta.repositories
+ custom = Repo().custom_repository()
# Replace the enabled repositories from user defined
if repos:
@@ -766,11 +718,11 @@ class Update:
for repo in enabled:
if check_for_local_repos(repo) is True:
continue
- print(f"{self.grey}Check repository [{self.cyan}{repo}{self.grey}] ... {self.endc}", end="", flush=True)
+ self.done_msg(repo)
if repo in default:
getattr(Initialization(False), repo)()
print(self.done, end="")
- elif repo in enabled:
+ elif repo in custom:
Initialization(False).custom(repo)
print(self.done, end="")
else:
@@ -778,6 +730,11 @@ class Update:
print() # new line at end
raise SystemExit()
+ def done_msg(self, repo):
+ print(f"{self.grey}Check repository "
+ f"[{self.cyan}{repo}{self.grey}] ... "
+ f"{self.endc}", end="", flush=True)
+
def check_exists_repositories(repo):
"""Checking if repositories exists by PACKAGES.TXT file
@@ -785,12 +742,10 @@ def check_exists_repositories(repo):
pkg_list = "PACKAGES.TXT"
if repo == "sbo":
pkg_list = "SLACKBUILDS.TXT"
- if check_for_local_repos(repo) is True:
+ elif check_for_local_repos(repo) is True:
pkg_list = "PACKAGES.TXT"
- return ""
if not os.path.isfile(f"{_meta_.lib_path}{repo}_repo/{pkg_list}"):
- return repo
- return ""
+ return False
def check_for_local_repos(repo):
diff --git a/slpkg/main.py b/slpkg/main.py
index bce8cd12..d76f78ba 100644
--- a/slpkg/main.py
+++ b/slpkg/main.py
@@ -88,11 +88,7 @@ class ArgParse(BlackList):
"clean"
]
- # checking if repositories exists
- enabled_repos = _meta_.repositories
- if len(self.args) > 1:
- repo = check_exists_repositories(args[1])
- if len(self.args) > 1 and self.args[0] in [
+ options = [
"-c", "--check",
"-l", "--list",
"-c", "--check",
@@ -101,11 +97,19 @@ class ArgParse(BlackList):
"-p", "--desc",
"-F", "--FIND",
"-f", "--find"
- ] and self.args[1] == repo and repo in enabled_repos:
+ ]
+
+ # checking if repositories exists
+ enabled_repos = _meta_.repositories
+ if len(self.args) > 1:
+ repo = self.args[1]
+ check = check_exists_repositories(repo)
+ if (len(self.args) > 1 and self.args[0] in options
+ and check is False and repo in enabled_repos):
print("\n Please update the packages lists. Run 'slpkg update'.\n"
" This command should be used to synchronize the packages\n"
" lists from the repositories that are enabled.\n")
- raise SystemExit()
+ raise SystemExit(1)
def help_version(self):
"""Help and version info
@@ -117,7 +121,7 @@ class ArgParse(BlackList):
self.args[1:] == []):
prog_version()
else:
- usage("")
+ usage("", 1)
def command_update(self):
"""Update package lists repositories
@@ -126,14 +130,14 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "update":
update.run(repos="")
elif (len(self.args) == 2 and self.args[0] == "update" and
- self.args[1].startswith("--repositories=")):
+ self.args[1].startswith("--repos=")):
repos = self.args[1].split("=")[-1].split(",")
for rp in repos:
if rp not in self.meta.repositories:
- repos.remove(rp)
+ usage(rp, 1)
update.run(repos)
else:
- usage("")
+ usage("", 1)
def command_upgrade(self):
"""Recreate repositories package lists
@@ -142,14 +146,14 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "upgrade":
upgrade.run(repos="")
elif (len(self.args) == 2 and self.args[0] == "upgrade" and
- self.args[1].startswith("--repositories=")):
+ self.args[1].startswith("--repos=")):
repos = self.args[1].split("=")[-1].split(",")
for rp in repos:
if rp not in self.meta.repositories:
- repos.remove(rp)
+ usage(rp, 1)
upgrade.run(repos)
else:
- usage("")
+ usage("", 1)
def command_update_slpkg(self):
"""Slpkg it self update
@@ -157,7 +161,7 @@ class ArgParse(BlackList):
if len(self.args) == 2 and self.args[0] == "update-slpkg":
it_self_update()
else:
- usage("")
+ usage("", 1)
def command_repo_enable(self):
"""Repositories enable/disable
@@ -166,7 +170,7 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "repo-enable":
RepoEnable().choose()
else:
- usage("")
+ usage("", 1)
def command_repo_list(self):
"""Repositories list
@@ -174,7 +178,7 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "repo-list":
RepoList().repos()
else:
- usage("")
+ usage("", 1)
def command_repo_add(self):
"""Add custom repositories
@@ -182,7 +186,7 @@ class ArgParse(BlackList):
if len(self.args) == 3 and self.args[0] == "repo-add":
Repo().add(self.args[1], self.args[2])
else:
- usage("")
+ usage("", 1)
def command_repo_remove(self):
"""Remove custom repositories
@@ -190,7 +194,7 @@ class ArgParse(BlackList):
if len(self.args) == 2 and self.args[0] == "repo-remove":
Repo().remove(self.args[1])
else:
- usage("")
+ usage("", 1)
def command_repo_info(self):
"""Repositories informations
@@ -201,9 +205,9 @@ class ArgParse(BlackList):
RepoInfo().view(self.args[1])
elif (len(self.args) > 1 and self.args[0] == "repo-info" and
self.args[1] not in RepoList().all_repos):
- usage(self.args[1])
+ usage(self.args[1], 1)
else:
- usage("")
+ usage("", 1)
def command_health(self):
"""Check package health
@@ -214,7 +218,7 @@ class ArgParse(BlackList):
self.args[1] == "--silent"):
PackageHealth(mode=self.args[1]).test()
else:
- usage("")
+ usage("", 1)
def command_deps_status(self):
"""Print dependencies status
@@ -234,7 +238,7 @@ class ArgParse(BlackList):
"--tree" in self.args and image):
DependenciesStatus(image).tree()
else:
- usage("")
+ usage("", 1)
def command_new_config(self):
"""Manage .new configuration files
@@ -242,14 +246,14 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "new-config":
NewConfig().run()
else:
- usage("")
+ usage("", 1)
def command_clean_tmp(self):
"""Clean all downloaded packages and sources"""
if len(self.args) == 1 and self.args[0] == "clean-tmp":
clean_tmp()
else:
- usage("")
+ usage("", 1)
def auto_build(self):
"""Auto built tool
@@ -261,7 +265,7 @@ class ArgParse(BlackList):
if len(self.args) >= 3 and self.args[0] in options:
AutoBuild(self.args[1], self.args[2:], self.meta.path).run()
else:
- usage("")
+ usage("", 1)
def pkg_list(self):
"""List of packages by repository
@@ -280,8 +284,7 @@ class ArgParse(BlackList):
if flag[2] == arg:
name = True
if arg not in flag:
- usage("")
- raise SystemExit()
+ usage("", 1)
if (len(self.args) > 1 and len(self.args) <= 5 and
self.args[0] in options):
if self.args[1] in self.meta.repositories:
@@ -290,9 +293,9 @@ class ArgParse(BlackList):
INDEX,
installed)
else:
- usage(self.args[1])
+ usage(self.args[1], 1)
else:
- usage("")
+ usage("", 1)
def pkg_upgrade(self):
"""Check and upgrade packages by repository
@@ -327,16 +330,16 @@ class ArgParse(BlackList):
SBoInstall(sbo_upgrade(skip, flag), flag).start(
is_upgrade=True)
else:
- usage(self.args[1])
+ usage(self.args[1], 1)
elif len(self.args) == 1 and self.args[0] in options:
Updates(repo="").ALL()
elif len(self.args) == 2 and self.args[0] in options:
Updates(self.args[1]).run()
elif (len(self.args) >= 2 and self.args[0] in options and
self.args[1] not in self.meta.repositories):
- usage(self.args[1])
+ usage(self.args[1], 1)
else:
- usage("")
+ usage("", 1)
def __pkg_upgrade_flags(self, flags):
"""Manage flags for package upgrade option
@@ -344,8 +347,7 @@ class ArgParse(BlackList):
# Check for typos or unssuported flags
for arg in self.args[2:]:
if arg not in flags:
- usage("")
- raise SystemExit()
+ usage("", 1)
flag, skip = [], ""
if flags[0] in self.args:
@@ -397,9 +399,9 @@ class ArgParse(BlackList):
self.args[1] in self.meta.repositories):
SBoInstall(self.args[2:], flag).start(is_upgrade=False)
else:
- usage(self.args[1])
+ usage(self.args[1], 1)
else:
- usage("")
+ usage("", 1)
def pkg_tracking(self):
"""Tracking package dependencies
@@ -428,17 +430,16 @@ class ArgParse(BlackList):
for arg in self.args:
if arg.startswith("--"):
if arg not in additional_options:
- usage("")
- raise SystemExit()
+ usage("", 1)
if (len(self.args) >= 3 and len(self.args) <= 3 and
self.args[0] in options and
self.args[1] in self.meta.repositories):
TrackingDeps(self.args[2], self.args[1], flag).run()
elif (len(self.args) >= 2 and
self.args[1] not in self.meta.repositories):
- usage(self.args[1])
+ usage(self.args[1], 1)
else:
- usage("")
+ usage("", 1)
def sbo_network(self):
"""View slackbuilds packages
@@ -466,7 +467,7 @@ class ArgParse(BlackList):
additional_options[0] in flag):
SBoNetwork("", flag).view()
else:
- usage("sbo")
+ usage("sbo", 1)
def pkg_blacklist(self):
"""Manage blacklist packages
@@ -496,7 +497,7 @@ class ArgParse(BlackList):
self.args.remove(flag[1])
self.black_remove(self.args[1:])
else:
- usage("")
+ usage("", 1)
def pkg_queue(self):
"""Manage packages in queue
@@ -542,7 +543,7 @@ class ArgParse(BlackList):
queue.build()
queue.install()
else:
- usage("")
+ usage("", 1)
def bin_install(self):
"""Install Slackware binary packages
@@ -570,7 +571,7 @@ class ArgParse(BlackList):
packages = self.args[2:]
PackageManager(packages).install(flag)
else:
- usage("")
+ usage("", 1)
def bin_upgrade(self):
"""Install-upgrade Slackware binary packages
@@ -593,7 +594,7 @@ class ArgParse(BlackList):
packages = self.args[2:]
PackageManager(packages).upgrade(flag)
else:
- usage("")
+ usage("", 1)
def bin_remove(self):
"""Remove Slackware packages
@@ -637,7 +638,7 @@ class ArgParse(BlackList):
packages = [""]
PackageManager(packages).remove(flag, extra)
else:
- usage("")
+ usage("", 1)
def bin_find(self):
"""Find installed packages
@@ -663,7 +664,7 @@ class ArgParse(BlackList):
elif len(self.args) > 1 and self.args[0] in options:
PackageManager(packages).find(flag)
else:
- usage("")
+ usage("", 1)
def pkg_desc(self):
"""Print slack-desc by repository
@@ -687,8 +688,7 @@ class ArgParse(BlackList):
self.args.remove(arg)
break
if tag and tag not in colors:
- print(f"\nslpkg: Error: Available colors {colors}\n")
- raise SystemExit()
+ raise SystemExit(f"\nslpkg: Error: Available colors {colors}\n")
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in self.meta.repositories and tag in colors):
PkgDesc(self.args[2], self.args[1], tag).view()
@@ -697,9 +697,9 @@ class ArgParse(BlackList):
PkgDesc(self.args[2], self.args[1], paint="").view()
elif (len(self.args) > 1 and self.args[0] in options and
self.args[1] not in self.meta.repositories):
- usage(self.args[1])
+ usage(self.args[1], 1)
else:
- usage("")
+ usage("", 1)
def pkg_find(self):
"""Find packages from all enabled repositories
@@ -718,7 +718,7 @@ class ArgParse(BlackList):
if len(self.args) > 1 and self.args[0] in options:
FindFromRepos().find(packages, flag)
else:
- usage("")
+ usage("", 1)
def pkg_contents(self):
"""Print packages contents
@@ -731,7 +731,7 @@ class ArgParse(BlackList):
if len(self.args) > 1 and self.args[0] in options:
PackageManager(packages).display()
else:
- usage("")
+ usage("", 1)
def congiguration(self):
"""Manage slpkg configuration file
@@ -756,7 +756,7 @@ class ArgParse(BlackList):
self.args[1] == (command[2])):
conf.reset()
else:
- usage("")
+ usage("", 1)
def auto_detect(self, args):
"""Check for already Slackware binary packages exist
@@ -781,15 +781,14 @@ class ArgParse(BlackList):
if not_found:
for ntf in not_found:
self.msg.pkg_not_found("", ntf, "Not installed", "")
- raise SystemExit()
+ raise SystemExit(1)
def if_checklist(self):
try:
from dialog import Dialog
except ImportError:
- print("Require 'pythondialog': Install with 'slpkg -s sbo "
- "python3-pythondialog'")
- raise SystemExit()
+ raise SystemExit("Require 'pythondialog': Install with 'slpkg "
+ "-s sbo python3-pythondialog'")
def main():
@@ -800,8 +799,7 @@ def main():
argparse = ArgParse(args)
if len(args) == 0:
- usage("")
- raise SystemExit()
+ usage("", 1)
argparse.auto_detect(args)
@@ -861,7 +859,7 @@ def main():
try:
arguments[args[0]]()
except KeyError:
- usage("")
+ usage("", 1)
if __name__ == "__main__":
diff --git a/slpkg/messages.py b/slpkg/messages.py
index 48fc2e97..ba487e5d 100644
--- a/slpkg/messages.py
+++ b/slpkg/messages.py
@@ -32,6 +32,7 @@ class Msg:
"""
def __init__(self):
self.meta = _meta_
+ self.green = _meta_.color["GREEN"]
self.grey = _meta_.color["GREY"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
@@ -56,9 +57,11 @@ class Msg:
"""Print error message if build failed
"""
self.template(78)
- print(f"| Some error on the package {prgnam} [ {self.red}FAILED{self.endc} ]")
+ print(f"| Some error on the package {prgnam} "
+ f"[ {self.red}FAILED{self.endc} ]")
self.template(78)
- print(f"| See the log file in '{self.cyan}/var/log/slpkg/sbo/build_logs{self.endc}' "
+ print(f"| See the log file in '{self.cyan}"
+ f"/var/log/slpkg/sbo/build_logs{self.endc}' "
f"directory or read the README file")
self.template(78)
print() # new line at end
@@ -76,17 +79,19 @@ class Msg:
def reading(self):
"""Message reading
"""
- print(f"{self.grey}Reading package lists...{self.endc} ", end="", flush=True)
+ print(f"{self.grey}Reading package lists...{self.endc} ",
+ end="", flush=True)
def resolving(self):
"""Message resolving
"""
- print(f"{self.grey}Resolving dependencies...{self.endc} ", end="", flush=True)
+ print(f"{self.grey}Resolving dependencies...{self.endc} ",
+ end="", flush=True)
def done(self):
"""Message done
"""
- print(f"\b{self.grey}Done{self.endc}\n", end="")
+ print(f"\b{self.green}Done{self.endc}\n", end="")
def pkg(self, count):
"""Print singular plural
@@ -121,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):
@@ -157,5 +161,6 @@ class Msg:
def matching(self, packages):
"""Message for matching packages
"""
- print(f"\nNot found package with the name [ {self.cyan}{''.join(packages)}{self.endc} ]. "
- "Matching packages:\nNOTE: Not dependencies are resolved\n")
\ No newline at end of file
+ print(f"\nNot found package with the name "
+ f"[ {self.cyan}{''.join(packages)}{self.endc} ]. "
+ "Matching packages:\nNOTE: Not dependencies are resolved\n")
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/pkg/installed.py b/slpkg/pkg/installed.py
index 31c18dc4..5a3cd845 100644
--- a/slpkg/pkg/installed.py
+++ b/slpkg/pkg/installed.py
@@ -46,11 +46,11 @@ class GetFromInstalled:
"""
if self.find:
return split_package(self.find)[1]
- return ""
+ return self.find
def name(self):
"""Return installed package name
"""
if self.find:
return self.package
- return ""
+ return self.find
diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py
index 150dc2db..0fd1261b 100644
--- a/slpkg/pkg/manager.py
+++ b/slpkg/pkg/manager.py
@@ -67,7 +67,7 @@ class PackageManager(Utils):
if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n")
else:
- raise SystemExit()
+ raise SystemExit(1)
except subprocess.CalledProcessError:
self._not_found("Can't install", self.binary, pkg)
raise SystemExit(1)
@@ -82,7 +82,7 @@ class PackageManager(Utils):
if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n")
else:
- raise SystemExit()
+ raise SystemExit(1)
except subprocess.CalledProcessError:
self._not_found("Can't upgrade", self.binary, pkg)
raise SystemExit(1)
@@ -116,8 +116,7 @@ class PackageManager(Utils):
"\nAre you sure to remove {0} {1} [y/N]? ".format(
str(len(self.removed)), msg))
except EOFError:
- print() # new line at exit
- raise SystemExit()
+ raise SystemExit(1)
if remove_pkg in ["y", "Y"]:
self._check_if_used(self.binary)
for rmv in self.removed:
@@ -153,8 +152,7 @@ class PackageManager(Utils):
"other packages) [y/N]? ")
print()
except EOFError:
- print() # new line at exit
- raise SystemExit()
+ raise SystemExit("\n")
return remove_dep
def _get_removed(self):
@@ -296,8 +294,7 @@ class PackageManager(Utils):
if os.path.isfile(self.dep_path + package):
os.remove(self.dep_path + package) # remove log
except subprocess.CalledProcessError as er:
- print(er)
- raise SystemExit()
+ raise SystemExit(er)
def _rmv_deps(self, dependencies, package):
"""Remove dependencies
@@ -332,8 +329,7 @@ class PackageManager(Utils):
try:
self.skip = input(" > ").split()
except EOFError:
- print()
- raise SystemExit()
+ raise SystemExit("\n")
for s in self.skip:
if s in self.removed:
self.removed.remove(s)
@@ -503,8 +499,7 @@ class PackageManager(Utils):
print(pkg)
print() # new line at end
except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError):
- print() # new line at exit
- raise SystemExit()
+ raise SystemExit(1)
def _splitting_packages(self, pkg, repo, name):
"""Return package name from repositories
diff --git a/slpkg/pkg_find.py b/slpkg/pkg_find.py
index 93ef36ce..54b692db 100644
--- a/slpkg/pkg_find.py
+++ b/slpkg/pkg_find.py
@@ -46,7 +46,8 @@ class FindFromRepos:
def find(self, pkg, flag):
"""Start to find packages and print
"""
- print(f"Packages with name matching [ {self.cyan}{', '.join(pkg)}{self.endc} ]\n")
+ print(f"Packages with name matching [ {self.cyan}"
+ f"{', '.join(pkg)}{self.endc} ]\n")
self.msg.template(78)
print(f"| Repository Package {' ' * 54}Size")
self.msg.template(78)
@@ -68,8 +69,9 @@ class FindFromRepos:
self.cache = repo
self.count_pkg += 1
ver = self.sbo_version(repo, find)
- print(f" {self.cyan}{repo}{self.endc}{' ' * (12 - len(repo))}{find + ver} "
- f"{' ' * (53 -len(find + ver))}{size:>11}")
+ print(f" {self.cyan}{repo}{self.endc}"
+ f"{' ' * (11 - len(repo))}{find + ver} "
+ f"{' ' * (54 -len(find + ver))}{size:>11}")
print("\nFound summary")
print("=" * 79)
print(f"{self.grey}Total found {self.count_pkg} packages in "
diff --git a/slpkg/repoenable.py b/slpkg/repoenable.py
index fc66bc62..17949cfc 100644
--- a/slpkg/repoenable.py
+++ b/slpkg/repoenable.py
@@ -63,7 +63,7 @@ Keys: SPACE select or deselect the highlighted repositories,
TAB move focus
ENTER press the focused button
- Disabled <-------- REPOSITORIES -------> Enabled"""
+ Disabled <---------------- REPOSITORIES ----------------> Enabled"""
self.read_enabled()
self.read_disabled()
text, title, backtitle, status = keys, " Repositories ", "", False
@@ -104,7 +104,8 @@ Keys: SPACE select or deselect the highlighted repositories,
"""Update repositories.conf file with enabled or disabled
repositories
"""
- with open(f"{self.meta.conf_path}{self.repositories_conf}", "w") as new_conf:
+ with open(f"{self.meta.conf_path}"
+ f"{self.repositories_conf}", "w") as new_conf:
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
@@ -139,5 +140,6 @@ Keys: SPACE select or deselect the highlighted repositories,
self.msg.template(78)
print(f"| {total_enabled}")
self.msg.template(78)
- print(f"{self.grey}Total {len(self.selected)}/{len(self.enabled + self.disabled)} "
- f"repositories enabled.{self.endc}\n")
\ No newline at end of file
+ print(f"{self.grey}Total {len(self.selected)}/"
+ f"{len(self.enabled + self.disabled)} "
+ f"repositories enabled.{self.endc}\n")
diff --git a/slpkg/repoinfo.py b/slpkg/repoinfo.py
index 00baeee0..15c0c459 100644
--- a/slpkg/repoinfo.py
+++ b/slpkg/repoinfo.py
@@ -67,7 +67,8 @@ class RepoInfo(Utils):
self.form["Default:"] = "yes"
if (repo in self.meta.repositories and
- os.path.isfile(f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT")):
+ os.path.isfile(f"{self.meta.lib_path}"
+ f"{repo}_repo/PACKAGES.TXT")):
status = f"{self.green}enabled{self.endc}"
if repo != "sbo":
@@ -75,10 +76,8 @@ class RepoInfo(Utils):
size = units(data[1], data[2])
self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo]
- self.form["Total compressed packages:"] = "{0} {1}".format(
- str(size[1][0]), str(size[0][0]))
- self.form["Total uncompressed packages:"] = "{0} {1}".format(
- str(size[1][1]), str(size[0][1]))
+ self.form["Total compressed packages:"] = f"{str(size[1][0])} {str(size[0][0])}"
+ self.form["Total uncompressed packages:"] = f"{str(size[1][1])} {str(size[0][1])}"
self.form["Number of packages:"] = data[0]
self.form["Status:"] = status
self.form["Last updated:"] = data[3]
@@ -130,4 +129,4 @@ class RepoInfo(Utils):
f"{self.meta.log_path}{repo}/ChangeLog.txt")
last_upd = log.split("\n", 1)[0]
- return [sum_pkgs, size, unsize, last_upd]
\ No newline at end of file
+ return [sum_pkgs, size, unsize, last_upd]
diff --git a/slpkg/repolist.py b/slpkg/repolist.py
index 449fd383..e9c98f85 100644
--- a/slpkg/repolist.py
+++ b/slpkg/repolist.py
@@ -47,8 +47,8 @@ class RepoList:
def_cnt, cus_cnt = 0, 0
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}".format(
- "| Repo id", " " * 2,
- "Repo URL", " " * 44,
+ "| Repo_id", " " * 2,
+ "Repo_URL", " " * 44,
"Default", " " * 3,
"Status"))
self.msg.template(78)
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/sbo/autobuild.py b/slpkg/sbo/autobuild.py
index 250c8656..3b292d17 100644
--- a/slpkg/sbo/autobuild.py
+++ b/slpkg/sbo/autobuild.py
@@ -64,9 +64,9 @@ class AutoBuild:
"""Check if SlackBuild archive.tar.gz and sources exist
"""
if not os.path.isfile(self.path + self.script):
- print("\nslpkg: Error: SlackBuild archive.tar.gz not found\n")
- raise SystemExit()
+ raise SystemExit("\nslpkg: Error: SlackBuild archive.tar.gz "
+ "not found\n")
for src in self.sources:
if not os.path.isfile(self.path + src):
- print(f"\nslpkg: Error: Source file '{src}' not found\n")
- raise SystemExit()
+ raise SystemExit(f"\nslpkg: Error: Source file '{src}' "
+ f"not found\n")
diff --git a/slpkg/sbo/build_num.py b/slpkg/sbo/build_num.py
index 94ba9fc5..bbc8c08e 100644
--- a/slpkg/sbo/build_num.py
+++ b/slpkg/sbo/build_num.py
@@ -40,9 +40,11 @@ class BuildNumber(Utils):
def get(self):
num = "NO_BUILD"
if self.sbo_url:
- SlackBuild = URL(f"{self.sbo_url}{self.pkg}.SlackBuild").reading()
+ SlackBuild = URL(f"{self.sbo_url}"
+ f"{self.pkg}.SlackBuild").get_request()
else:
- SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/{self.pkg}.SlackBuild")
+ SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/"
+ f"{self.pkg}.SlackBuild")
for line in SlackBuild.splitlines():
line = line.lstrip()
if line.startswith("BUILD="):
diff --git a/slpkg/sbo/check.py b/slpkg/sbo/check.py
index d26a04dd..78c42312 100644
--- a/slpkg/sbo/check.py
+++ b/slpkg/sbo/check.py
@@ -62,4 +62,4 @@ def sbo_list():
"""
for pkg in os.listdir(_meta_.pkg_path):
if pkg.endswith("_SBo"):
- yield pkg
\ No newline at end of file
+ yield pkg
diff --git a/slpkg/sbo/dependency.py b/slpkg/sbo/dependency.py
index b8c51138..ce666319 100644
--- a/slpkg/sbo/dependency.py
+++ b/slpkg/sbo/dependency.py
@@ -23,6 +23,7 @@
import sys
+from functools import lru_cache
from slpkg.blacklist import BlackList
from slpkg.__metadata__ import MetaData as _meta_
@@ -41,6 +42,7 @@ class Requires(BlackList):
self.blacklist = list(self.get_black())
self.dep_results = []
+ @lru_cache
def sbo(self, name):
"""Build all dependencies of a package
"""
@@ -55,14 +57,15 @@ class Requires(BlackList):
# if require in blacklist
if "%README%" not in req and req not in self.blacklist:
dependencies.append(req)
- self.deep_check(dependencies)
+ self.deep_check(tuple(dependencies))
return self.dep_results
else:
return []
+ @lru_cache
def deep_check(self, dependencies):
"""Checking if dependencies are finnished
"""
if dependencies:
self.dep_results.append(dependencies)
- [self.sbo(dep) for dep in dependencies]
\ No newline at end of file
+ [self.sbo(dep) for dep in dependencies]
diff --git a/slpkg/sbo/network.py b/slpkg/sbo/network.py
index 36c4ea43..f8f2b005 100644
--- a/slpkg/sbo/network.py
+++ b/slpkg/sbo/network.py
@@ -172,8 +172,7 @@ class SBoNetwork(BlackList, Utils):
message = " Choose an option > "
self.choice = input(f"{self.grey}{message}{self.endc}")
except EOFError:
- print()
- raise SystemExit()
+ raise SystemExit('\n')
try:
print("{0}\x1b[1A{1}{2}{3}\n".format(
" " * len(message), self.cyan, commands[self.choice],
@@ -301,10 +300,9 @@ class SBoNetwork(BlackList, Utils):
status = False
pkg = DialogUtil(data, text, title, backtitle, status).checklist()
if pkg and len(pkg) > 1:
- print("\nslpkg: Error: Choose only one package")
- raise SystemExit()
+ raise SystemExit("\nslpkg: Error: Choose only one package")
if pkg is None:
- raise SystemExit()
+ raise SystemExit(1)
self.name = "".join(pkg)
os.system("clear")
diff --git a/slpkg/sbo/queue.py b/slpkg/sbo/queue.py
index 0bd3cf60..b7caf30e 100644
--- a/slpkg/sbo/queue.py
+++ b/slpkg/sbo/queue.py
@@ -136,8 +136,8 @@ class QueuePkgs(Utils):
BuildPackage(script, sources, self.meta.build_path,
auto=False).build()
else:
- print("\nPackages not found in the queue for building\n")
- raise SystemExit(1)
+ raise SystemExit("\nPackages not found in the queue for "
+ "building\n")
def install(self):
"""Install packages from queue
@@ -152,8 +152,8 @@ class QueuePkgs(Utils):
binary = slack_package(prgnam)
PackageManager(binary).upgrade(flag="--install-new")
else:
- print(f"\nPackage {prgnam} not found in the {self.meta.output} for "
- f"installation\n")
+ print(f"\nPackage {prgnam} not found in the "
+ f"{self.meta.output} for installation\n")
else:
- print("\nPackages not found in the queue for installation\n")
- raise SystemExit(1)
+ raise SystemExit("\nPackages not found in the queue for "
+ "installation\n")
diff --git a/slpkg/sbo/read.py b/slpkg/sbo/read.py
index 9109e699..9ca0e38e 100644
--- a/slpkg/sbo/read.py
+++ b/slpkg/sbo/read.py
@@ -34,19 +34,19 @@ class ReadSBo:
def readme(self, sbo_readme):
"""Read SlackBuild README file
"""
- return URL(self.sbo_url + sbo_readme).reading()
+ return URL(self.sbo_url + sbo_readme).get_request()
def info(self, name, sbo_file):
"""Read info file
"""
- return URL(self.sbo_url + name + sbo_file).reading()
+ return URL(self.sbo_url + name + sbo_file).get_request()
def slackbuild(self, name, sbo_file):
"""Read SlackBuild file
"""
- return URL(self.sbo_url + name + sbo_file).reading()
+ return URL(self.sbo_url + name + sbo_file).get_request()
def doinst(self, doinst_sh):
"""Read SlackBuild doinst.sh
"""
- return URL(self.sbo_url + doinst_sh).reading()
+ return URL(self.sbo_url + doinst_sh).get_request()
diff --git a/slpkg/sbo/slackbuild.py b/slpkg/sbo/slackbuild.py
index 6b38314a..224e234f 100644
--- a/slpkg/sbo/slackbuild.py
+++ b/slpkg/sbo/slackbuild.py
@@ -153,12 +153,13 @@ class SBoInstall(BlackList, Utils):
if self.match and [""] != self.slackbuilds:
print("\nMatching summary")
print("=" * 79)
- print(f"Total {count_total} matching packages\n")
- raise SystemExit(1)
+ raise SystemExit(f"Total {count_total} matching packages\n")
print("\nInstalling summary")
print("=" * 79)
- print(f"{self.grey}Total {count_total} {self.msg.pkg(count_total)}.")
- print(f"{self.count_uni} {self.msg.pkg(self.count_uni)} will be installed, "
+ print(f"{self.grey}Total {count_total} "
+ f"{self.msg.pkg(count_total)}.")
+ print(f"{self.count_uni} {self.msg.pkg(self.count_uni)} "
+ f"will be installed, "
f"{self.count_ins} already installed and "
f"{self.count_upg} {self.msg.pkg(self.count_upg)}")
print(f"will be upgraded.{self.endc}\n")
@@ -338,14 +339,16 @@ class SBoInstall(BlackList, Utils):
self.msg.template(78)
elif self.unst[0] in src_link or self.unst[1] in src_link:
self.msg.template(78)
- print(f"| Package {prgnam} {self.red}{''.join(src_link)}{self.endc}")
+ print(f"| Package {prgnam} {self.red}"
+ f"{''.join(src_link)}{self.endc}")
self.msg.template(78)
else:
sbo_url = sbo_search_pkg(pkg)
sbo_link = SBoLink(sbo_url).tar_gz()
script = sbo_link.split("/")[-1]
if self.meta.sbosrcarch in ["on", "ON"]:
- src_link = list(self.sbosrcarsh(prgnam, sbo_link, src_link))
+ src_link = list(self.sbosrcarsh(prgnam, sbo_link,
+ src_link))
Download(self.build_folder, sbo_link.split(),
repo="sbo").start()
Download(self._SOURCES, src_link, repo="sbo").start()
@@ -357,10 +360,12 @@ class SBoInstall(BlackList, Utils):
binary = slack_package(prgnam)
if os.path.isfile("".join(binary)):
if GetFromInstalled(pkg).name() == pkg:
- print(f"[ {self.yellow}Upgrading{self.endc} ] --> {prgnam}")
+ print(f"[ {self.yellow}Upgrading{self.endc} ] --> "
+ f"{prgnam}")
upgraded.append(prgnam)
else:
- print(f"[ {self.green}Installing{self.endc} ] --> {prgnam}")
+ print(f"[ {self.green}Installing{self.endc} ] --> "
+ f"{prgnam}")
installs.append(prgnam)
if ("--rebuild" in self.flag and
GetFromInstalled(pkg).name() == pkg):
diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py
index 60dfad35..f92e5ac0 100644
--- a/slpkg/slack/patches.py
+++ b/slpkg/slack/patches.py
@@ -68,11 +68,11 @@ class Patches(BlackList, Utils):
self.msg = Msg()
self.version = self.meta.slack_rel
self.patch_path = self.meta.slpkg_tmp_patches
+ self.count_added = 0
+ self.count_upg = 0
self.pkg_for_upgrade = []
self.dwn_links = []
self.upgrade_all = []
- self.count_added = 0
- self.count_upg = 0
self.upgraded = []
self.installed = []
self.comp_sum = []
@@ -80,9 +80,9 @@ class Patches(BlackList, Utils):
self.msg.checking()
if self.version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT",
- "patches/")).reading()
+ "patches/")).get_request()
else:
- self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading()
+ self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).get_request()
def start(self):
"""Install new patches from official Slackware mirrors
@@ -251,8 +251,7 @@ class Patches(BlackList, Utils):
answer = input("\nThe kernel has been upgraded, "
"reinstall boot loader [L/E/G]? ")
except EOFError:
- print()
- raise SystemExit()
+ raise SystemExit("\n")
if answer in ["L"]:
subprocess.call("lilo", shell=True)
break
@@ -268,7 +267,7 @@ class Patches(BlackList, Utils):
"""This replace slackpkg ChangeLog.txt file with new
from Slackware official mirrors after update distribution.
"""
- NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading()
+ NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).get_request()
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"):
diff --git a/slpkg/slack/slack_version.py b/slpkg/slack/slack_version.py
index dc3e7ea3..23940232 100644
--- a/slpkg/slack/slack_version.py
+++ b/slpkg/slack/slack_version.py
@@ -40,5 +40,4 @@ def slack_ver():
return (".".join(version[:2]))
else:
return (".".join(version))
- else:
- return _meta_.slackware_version
+ return _meta_.slackware_version
diff --git a/slpkg/slack/slackware_repo.py b/slpkg/slack/slackware_repo.py
index 4c27820b..639e3c94 100644
--- a/slpkg/slack/slackware_repo.py
+++ b/slpkg/slack/slackware_repo.py
@@ -39,4 +39,4 @@ def slackware_repository():
for pkg in slack_repo[0]:
names.append(split_package(pkg)[0])
packages.append(pkg[:-4])
- return packages, names
\ No newline at end of file
+ return packages, names
diff --git a/slpkg/slpkg_update.py b/slpkg/slpkg_update.py
index 60745e1b..ccef7604 100644
--- a/slpkg/slpkg_update.py
+++ b/slpkg/slpkg_update.py
@@ -47,7 +47,7 @@ def it_self_update():
_meta_.__all__,
branch,
_meta_.__all__))
- version_data = URL(ver_link).reading()
+ version_data = URL(ver_link).get_request()
for line in version_data.splitlines():
line = line.strip()
@@ -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
@@ -96,5 +95,6 @@ def it_self_update():
subprocess.call("sh install.sh", shell=True)
else:
- print(f"\n{_meta_.__all__}: There is no new version, already used the last!\n")
- raise SystemExit()
\ No newline at end of file
+ print(f"\n{_meta_.__all__}: There is no new version, "
+ "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
diff --git a/slpkg/url_read.py b/slpkg/url_read.py
index 385774bf..18fc8c33 100644
--- a/slpkg/url_read.py
+++ b/slpkg/url_read.py
@@ -40,12 +40,13 @@ class URL:
else:
self.http = urllib3.PoolManager()
- def reading(self):
+ def get_request(self):
"""Open url and read
"""
try:
f = self.http.request('GET', self.link)
return f.data.decode("utf-8", "ignore")
except urllib3.exceptions.NewConnectionError:
- print(f"\n{self.red}Can't read the file '{self.link.split('/')[-1]}'{self.endc}")
+ print(f"\n{self.red}Can't read the file "
+ f"'{self.link.split('/')[-1]}'{self.endc}")
return " "
diff --git a/tests/test_file_size.py b/tests/test_file_size.py
index a40d08dc..b3ebe1d0 100644
--- a/tests/test_file_size.py
+++ b/tests/test_file_size.py
@@ -1,12 +1,19 @@
+import unittest
from slpkg.file_size import FileSize
-def test_FileSize():
- """Testing the remote and local servers
- """
- url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt"
- lc = "tests/test_units.py"
- fs1 = FileSize(url)
- fs2 = FileSize(lc)
- assert fs1.server() is not None
- assert fs2.local() is not None
+class TestFileSize(unittest.TestCase):
+
+ def test_FileSize(self):
+ """Testing the remote and local servers
+ """
+ url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt"
+ lc = "test_units.py"
+ fs1 = FileSize(url)
+ fs2 = FileSize(lc)
+ self.assertIsNotNone(fs1.server())
+ self.assertIsNotNone(fs2.local())
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_installed.py b/tests/test_installed.py
new file mode 100644
index 00000000..150f0cef
--- /dev/null
+++ b/tests/test_installed.py
@@ -0,0 +1,23 @@
+import unittest
+from slpkg.pkg.installed import GetFromInstalled
+
+
+class TestPkgInstalled(unittest.TestCase):
+
+ def setUp(self):
+ self.pkg_name = 'aaa_base'
+ self.pkg_ver = '15.0'
+ self.installed = GetFromInstalled('aaa_base')
+
+ def test_pkg_name(self):
+ """Testing the installed package name
+ """
+ self.assertEqual(self.pkg_name, self.installed.name())
+
+ def test_pkg_version(self):
+ """Testing the version of installed package"""
+ self.assertEqual(self.pkg_ver, self.installed.version())
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_md5sum.py b/tests/test_md5sum.py
index cf1590ff..a8d1080d 100644
--- a/tests/test_md5sum.py
+++ b/tests/test_md5sum.py
@@ -1,15 +1,21 @@
+import unittest
from slpkg.md5sum import md5
-def test_md5_superuser():
- """Testing checksum for superuser.py file
- """
- result = md5('slpkg/superuser.py')
- assert result == "c6a3576c247bda199c75b43540bfc3d7"
+class TestMd5(unittest.TestCase):
+
+ def test_md5_superuser(self):
+ """Testing checksum for superuser.py file
+ """
+ result = md5('test_file_size.py')
+ self.assertEqual(result, "e3e7b72be80efc922b0e1f1cd409a417")
+
+ def test_md5_security(self):
+ """Testing checksum for security.py file
+ """
+ result = md5('test_units.py')
+ self.assertEqual(result, "58a694171449e923414e3e3339a0097e")
-def test_md5_security():
- """Testing checksum for security.py file
- """
- result = md5('slpkg/security.py')
- assert result == "eb8dbea4dec6d72353d30475670389f0"
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_sbo_grep.py b/tests/test_sbo_grep.py
new file mode 100644
index 00000000..b160862e
--- /dev/null
+++ b/tests/test_sbo_grep.py
@@ -0,0 +1,49 @@
+import unittest
+from slpkg.sbo.greps import SBoGrep
+
+
+class TestSBoGreps(unittest.TestCase):
+
+ def setUp(self):
+ self.grep = SBoGrep('Flask')
+
+ def test_source(self):
+ """Test package source
+ """
+ source = self.grep.source()
+ flask_source = ('https://files.pythonhosted.org/packages/4e/0b/'
+ 'cb02268c90e67545a0e3a37ea1ca3d45de3aca43ceb7dbf'
+ '1712fb5127d5d/Flask-1.1.2.tar.gz')
+ self.assertEqual(source, flask_source)
+
+ def test_requires(self):
+ """Test package requires
+ """
+ requires = self.grep.requires()
+ flask_dep = ['werkzeug', 'python3-itsdangerous', 'click']
+ self.assertListEqual(requires, flask_dep)
+
+ def test_version(self):
+ """Test package version
+ """
+ version = self.grep.version()
+ flask_ver = '1.1.2'
+ self.assertEqual(version, flask_ver)
+
+ def test_checksum(self):
+ """Test package checksum
+ """
+ checksum = self.grep.checksum()
+ flask_md5 = ['0da4145d172993cd28a6c619630cc19c']
+ self.assertListEqual(checksum, flask_md5)
+
+ def test_description(self):
+ """Test package description
+ """
+ desc = self.grep.description()
+ flask_desc = 'Flask (Microframework for Python)'
+ self.assertEqual(desc, flask_desc)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_search_package.py b/tests/test_search_package.py
index 2798e28f..52ca9798 100644
--- a/tests/test_search_package.py
+++ b/tests/test_search_package.py
@@ -1,22 +1,25 @@
-import pytest
+import unittest
from slpkg.binary.search import search_pkg
from slpkg.sbo.search import sbo_search_pkg
-@pytest.mark.skip(reason="no way of currently testing in Gitlab")
-def test_search():
- """Testing found the name from binaries repos
- """
- name = "vlc"
- repo = "alien"
- test = search_pkg(name, repo)
- assert name == test
+class TestFindPkg(unittest.TestCase):
+
+ def test_search(self):
+ """Testing found the name from binaries repos
+ """
+ name = "vlc"
+ repo = "alien"
+ test = search_pkg(name, repo)
+ self.assertEqual(name, test)
+
+ def test_sbo_search(self):
+ """Testing found the name from binaries repos
+ """
+ name = "slpkg"
+ test = sbo_search_pkg(name).split("/")[-2]
+ self.assertEqual(name, test)
-@pytest.mark.skip(reason="no way of currently testing in Gtilab")
-def test_sbo_search():
- """Testing found the name from binaries repos
- """
- name = "slpkg"
- test = sbo_search_pkg(name).split("/")[-2]
- assert name == test
\ No newline at end of file
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_slack_version.py b/tests/test_slack_version.py
new file mode 100644
index 00000000..6d693fb6
--- /dev/null
+++ b/tests/test_slack_version.py
@@ -0,0 +1,15 @@
+import unittest
+from slpkg.slack.slack_version import slack_ver
+
+
+class TestSlackVersion(unittest.TestCase):
+
+ def test_slack_version(self):
+ """Testing the current Slackware version
+ """
+ ver = '15.0'
+ self.assertEqual(ver, slack_ver())
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_split_package.py b/tests/test_split_package.py
new file mode 100644
index 00000000..aac0aa4d
--- /dev/null
+++ b/tests/test_split_package.py
@@ -0,0 +1,26 @@
+import unittest
+from slpkg.splitting import split_package
+from slpkg.pkg.find import searching
+
+
+class TestSplitting(unittest.TestCase):
+
+ def test_split_pkg(self):
+ path = '/var/log/packages/'
+ pkg_1 = ''.join(list(searching('slpkg', path)))
+ pkg_2 = ''.join(list(searching('akonadi-mime', path)))
+ pkg_3 = ''.join(list(searching('autoconf-archive', path)))
+ pkg_4 = ''.join(list(searching('bind', path)))
+
+ self.assertListEqual(['slpkg', '3.9.6', 'x86_64', '1'],
+ split_package(pkg_1))
+ self.assertListEqual(['akonadi-mime', '21.12.1', 'x86_64', '1'],
+ split_package(pkg_2))
+ self.assertListEqual(['autoconf-archive', '2021.02.19', 'noarch', '1'],
+ split_package(pkg_3))
+ self.assertListEqual(['bind', '9.16.27', 'x86_64', '1'],
+ split_package(pkg_4))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_units.py b/tests/test_units.py
index d1f0ef53..096aa786 100644
--- a/tests/test_units.py
+++ b/tests/test_units.py
@@ -1,7 +1,19 @@
+import unittest
from slpkg.sizes import units
-def test_units():
- """Testing the units metrics
- """
- assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']])
\ No newline at end of file
+class TetsUnits(unittest.TestCase):
+
+ def test_units(self):
+ """Testing the units metrics
+ """
+ self.assertCountEqual((["Kb", "Kb"], [100, 100]),
+ units(["100"], ["100"]))
+ self.assertCountEqual((["Mb", "Mb"], [1000, 1000]),
+ units(["1024000"], ["1024000"]))
+ self.assertCountEqual((["Gb", "Gb"], [976.56, 976.56]),
+ units(["1024000000"], ["1024000000"]))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 540d578e..f176f213 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,17 +1,34 @@
+import unittest
from slpkg.utils import Utils
-def test_dimensional_list():
- """Testing dimesional list util
- """
- lists = [[1, 2, 3, 4, 5]]
- utils = Utils()
- assert [1, 2, 3, 4, 5] == utils.dimensional_list(lists)
+class TestUtils(unittest.TestCase):
+
+ def setUp(self):
+ self.utils = Utils()
+
+ def test_dimensional_list(self):
+ """Testing dimesional list util
+ """
+ lists = [[1, 2, 3, 4, 5]]
+ self.assertListEqual([1, 2, 3, 4, 5],
+ self.utils.dimensional_list(lists))
+
+ def test_remove_dbs(self):
+ """Testing removing doubles item from list
+ """
+ lists = [1, 2, 3, 3, 4, 5, 2, 1]
+ self.assertListEqual([1, 2, 3, 4, 5], self.utils.remove_dbs(lists))
+
+ def test_case_sensitive(self):
+ """Testing case sensitive
+ """
+ lists = ['Vlc', 'OpenOffice', 'APScheduler']
+ dictionary = {'vlc': 'Vlc',
+ 'openoffice': 'OpenOffice',
+ 'apscheduler': 'APScheduler'}
+ self.assertDictEqual(dictionary, self.utils.case_sensitive(lists))
-def test_remove_dbs():
- """Testing removing doubles item from list
- """
- lists = [1, 2, 3, 3, 4, 5, 2, 1]
- utils = Utils()
- assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)
\ No newline at end of file
+if __name__ == "__main__":
+ unittest.main()