From eea7997c789bb4eef8fb9b0b30c6eeedcac62262 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 16 Feb 2020 19:07:27 +0100 Subject: [PATCH 01/13] Updated utils Signed-off-by: Dimitris Zlatanidis --- slpkg/pkg/build.py | 4 ++-- slpkg/pkg/manager.py | 17 +++++++++-------- slpkg/repoenable.py | 6 +++--- slpkg/sbo/queue.py | 4 ++-- slpkg/status_deps.py | 5 ++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/slpkg/pkg/build.py b/slpkg/pkg/build.py index 5d591f89..9625a953 100644 --- a/slpkg/pkg/build.py +++ b/slpkg/pkg/build.py @@ -39,7 +39,7 @@ from slpkg.__metadata__ import MetaData as _meta_ from slpkg.sbo.greps import SBoGrep -class BuildPackage: +class BuildPackage(Utils): """Build SBo packages from source """ def __init__(self, script, sources, path, auto): @@ -118,7 +118,7 @@ class BuildPackage: """ new_sources = [] for src in self.sources: - new_sources.append(Utils().fix_file_name(src)) + new_sources.append(self.fix_file_name(src)) self.sources = new_sources def _create_md5_dict(self): diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py index 87220452..e1fedbe2 100644 --- a/slpkg/pkg/manager.py +++ b/slpkg/pkg/manager.py @@ -39,7 +39,7 @@ from slpkg.__metadata__ import MetaData as _meta_ from slpkg.slack.slackware_repo import slackware_repository -class PackageManager: +class PackageManager(Utils): """Package manager class for install, upgrade, reinstall, remove, find and display packages""" def __init__(self, binary): @@ -253,7 +253,7 @@ class PackageManager: """ self.size = 0 packages = [] - dependencies = (Utils().read_file(path + package)).splitlines() + dependencies = (self.read_file(path + package)).splitlines() for dep in dependencies: if GetFromInstalled(dep).name(): ver = GetFromInstalled(dep).version() @@ -343,7 +343,7 @@ class PackageManager: if "--check-deps" in self.extra: package, dependency, pkg_dep = [], [], [] for pkg in find_package("", self.dep_path): - deps = Utils().read_file(self.dep_path + pkg) + deps = self.read_file(self.dep_path + pkg) for rmv in removes: if GetFromInstalled(rmv).name() and rmv in deps.split(): pkg_dep.append(f"{rmv} is dependency of the package --> {pkg}") @@ -435,7 +435,7 @@ class PackageManager: def _sizes(self, package): """Package size summary """ - data = Utils().read_file(self.meta.pkg_path + package) + data = self.read_file(self.meta.pkg_path + package) for line in data.splitlines(): if line.startswith("UNCOMPRESSED PACKAGE SIZE:"): digit = float((''.join(re.findall( @@ -456,7 +456,7 @@ class PackageManager: find = find_package(f"{name}{ver}{self.meta.sp}", self.meta.pkg_path) if find: - package = Utils().read_file( + package = self.read_file( self.meta.pkg_path + "".join(find)) print(package) else: @@ -537,12 +537,13 @@ class PackageManager: if repo == "sbo": if (os.path.isfile( self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT")): - packages = Utils().read_file(self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT") + packages = self.read_file(f"{self.meta.lib_path}" + "sbo_repo/SLACKBUILDS.TXT") else: if (os.path.isfile( self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")): - packages = Utils().read_file(self.meta.lib_path + "{0}_repo/" - "PACKAGES.TXT".format(repo)) + packages = self.read_file(f"{self.meta.lib_path}" + f"{repo}_repo/PACKAGES.TXT") return packages def list_color_tag(self, pkg): diff --git a/slpkg/repoenable.py b/slpkg/repoenable.py index 3b60ea8e..261bc620 100644 --- a/slpkg/repoenable.py +++ b/slpkg/repoenable.py @@ -30,7 +30,7 @@ from slpkg.dialog_box import DialogUtil from slpkg.__metadata__ import MetaData as _meta_ -class RepoEnable: +class RepoEnable(Utils): """Read repositories.conf file and update with new enabled or disabled repositories """ @@ -43,8 +43,8 @@ class RepoEnable: self.tag = "[REPOSITORIES]" self.tag_line = False self.repositories_conf = "repositories.conf" - self.conf = Utils().read_file( - self.meta.conf_path + self.repositories_conf) + self.conf = self.read_file(f"{self.meta.conf_path}" + f"{self.repositories_conf}") self.enabled = [] self.disabled = [] self.selected = [] diff --git a/slpkg/sbo/queue.py b/slpkg/sbo/queue.py index 44b90249..c46112b6 100644 --- a/slpkg/sbo/queue.py +++ b/slpkg/sbo/queue.py @@ -39,7 +39,7 @@ from slpkg.sbo.search import sbo_search_pkg from slpkg.sbo.slack_find import slack_package -class QueuePkgs: +class QueuePkgs(Utils): """Manage SBo packages, add or remove for building or installation """ @@ -68,7 +68,7 @@ class QueuePkgs: with open(self.queue_list, "w") as queue: for line in queue_file: queue.write(line) - self.queued = Utils().read_file(self.queue_list) + self.queued = self.read_file(self.queue_list) def packages(self): """Return queue list from /var/lib/queue/queue_list diff --git a/slpkg/status_deps.py b/slpkg/status_deps.py index 94f4fa9f..eacaef5d 100644 --- a/slpkg/status_deps.py +++ b/slpkg/status_deps.py @@ -33,14 +33,13 @@ from slpkg.__metadata__ import MetaData as _meta_ from slpkg.pkg.find import find_package -class DependenciesStatus: +class DependenciesStatus(Utils): """Print dependencies status used by packages """ def __init__(self, image): 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"] @@ -61,7 +60,7 @@ class DependenciesStatus: if os.path.isfile(f"{self.meta.pkg_path}{pkg}"): name = split_package(pkg)[0] for log in self.logs: - deps = self.utils.read_file(f"{self.dep_path}{log}") + deps = self.read_file(f"{self.dep_path}{log}") for dep in deps.splitlines(): if name == dep: if name not in self.dmap.keys(): From 83912a74a918e29a6f6cfa00f39e89d5f62f9612 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 09:50:44 +0100 Subject: [PATCH 02/13] Added bz2 archive Signed-off-by: Dimitris Zlatanidis --- install.sh | 3 ++- slackbuild/slpkg.SlackBuild | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index d3b9c8c6..38f900aa 100755 --- a/install.sh +++ b/install.sh @@ -34,7 +34,8 @@ VERSION=${VERSION:-$(__version)} # Installation script. # With this script allows you to install the slpkg as a Slackware package binary file. # Support wget download. -ARCHIVES="$PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION.zip v$VERSION.tar.gz v$VERSION.zip" +ARCHIVES="$PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION.zip v$VERSION.tar.gz v$VERSION.zip \ + $PRGNAM-$VERSION.tar.bz2" cd .. for file in $ARCHIVES; do if [ -f $file ]; then diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index b9aca314..cbdb42bd 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -68,7 +68,8 @@ mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION tar xvf $CWD/$PRGNAM-$VERSION.tar.gz || tar xvf $CWD/v$VERSION.tar.gz \ - || unzip $CWD/$PRGNAM-$VERSION.zip || unzip $CWD/v$VERSION.zip + || $CWD/$PRGNAM-$VERSION.tar.bz2 || unzip $CWD/$PRGNAM-$VERSION.zip \ + || unzip $CWD/v$VERSION.zip cd $PRGNAM-$VERSION chown -R root:root . find -L . \ @@ -108,4 +109,4 @@ cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz} -$INSTALL $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz \ No newline at end of file +$INSTALL $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz From fbaec8bd100024f867fa9e47a0ad4fc517ea2ff4 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 12:16:48 +0100 Subject: [PATCH 03/13] Fixed counting packages Signed-off-by: Dimitris Zlatanidis --- slpkg/binary/install.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 6d4d8303..66eb6642 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -23,6 +23,7 @@ import os +from itertools import zip_longest from pkg_resources import parse_version from slpkg.utils import Utils @@ -100,7 +101,7 @@ class BinaryInstall(BlackList): self.case_insensitive() # fix if packages is for upgrade self.is_upgrade = is_upgrade - mas_sum = dep_sum = sums = [0, 0, 0] + mas_sum = dep_sum = sums = 0, 0, 0, 0 self.msg.done() self.dependencies = self.resolving_deps() self.update_deps() @@ -124,22 +125,23 @@ class BinaryInstall(BlackList): if self.dependencies: print("Installing for dependencies:") dep_sum = self.views(self.dep_install, self.dep_comp_sum) - # sums[0] --> installed - # sums[1] --> upgraded - # sums[2] --> uninstall - sums = [sum(i) for i in zip(mas_sum, dep_sum)] + # sums[0] --> total packages + # sums[1] --> reinstall + # sums[2] --> upgraded + # sums[3] --> uninstall + sums = [sum(s) for s in zip_longest(mas_sum, dep_sum)] unit, size = units(self.comp_sum + self.dep_comp_sum, self.uncomp_sum + self.dep_uncomp_sum) if self.matching and [""] != self.packages: print("\nMatching summary") print("=" * 79) - print(f"Total {sum(sums)} matching packages\n") + print(f"Total {sums[0]} matching packages\n") raise SystemExit(1) print("\nInstalling summary") print("=" * 79) - print(f"{self.grey}Total {sum(sums)} {self.msg.pkg(sum(sums))}.") - print(f"{sums[2]} {self.msg.pkg(sums[2])} will be installed, {sums[1]} will be upgraded and " - f"{sums[0]} will be reinstalled.") + 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 " + 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}") @@ -282,14 +284,16 @@ class BinaryInstall(BlackList): def views(self, install, comp_sum): """Views packages """ - pkg_sum = uni_sum = upg_sum = 0 + pkg_sum = uni_sum = upg_sum = res_sum = 0 + # fix repositories align repo = self.repo + (" " * (6 - (len(self.repo)))) for pkg, comp in zip(install, comp_sum): + pkg_sum += 1 pkg_repo = split_package(pkg[:-4]) if find_package(pkg[:-4], self.meta.pkg_path): if "--reinstall" in self.flag: - pkg_sum += 1 + res_sum += 1 COLOR = self.meta.color["GREEN"] elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name(): COLOR = self.meta.color["YELLOW"] @@ -303,7 +307,7 @@ class BinaryInstall(BlackList): f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}" f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}" f"{' ' * (7-len(pkg_repo[3]))}{repo}{comp:>11}{' K'}") - return [pkg_sum, upg_sum, uni_sum] + return [pkg_sum, res_sum, upg_sum, uni_sum] def top_view(self): """Print packages status bar From f465d6f141fd1513587c4c3bfb64ff08bf067be4 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 12:21:17 +0100 Subject: [PATCH 04/13] Updated to version 3.8.3 Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 ++++ README.md | 2 +- slpkg/__metadata__.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b961babd..1c088b4d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +3.8.3 - 17/02/2020 +BugFix: +- Counting packages for binaries repositories + 3.8.2 - 15/02/2020 Fixed: - SBo repository view Packages and New version diff --git a/README.md b/README.md index 14e9a60a..a6f9477a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# slpkg 3.8.2 +# slpkg 3.8.3 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/slpkg/__metadata__.py b/slpkg/__metadata__.py index 1d316e12..da9254d5 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -76,7 +76,7 @@ class MetaData: __all__ = "slpkg" __author__ = "dslackw" - __version_info__ = (3, 8, 2) + __version_info__ = (3, 8, 3) __version__ = "{0}.{1}.{2}".format(*__version_info__) __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com" From 454aa5593803dc75c9dd064b04767833fb2c9fbc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 13:50:20 +0100 Subject: [PATCH 05/13] Updated utils Signed-off-by: Dimitris Zlatanidis --- slpkg/config.py | 5 ++--- slpkg/desc.py | 5 ++--- slpkg/downloader.py | 4 ++-- slpkg/init.py | 5 ++--- slpkg/new_config.py | 10 +++++----- slpkg/sbo/build_num.py | 4 ++-- slpkg/sbo/greps.py | 4 ++-- slpkg/sbo/network.py | 4 ++-- slpkg/slack/patches.py | 5 ++--- slpkg/tracking.py | 21 ++++++++++----------- 10 files changed, 31 insertions(+), 36 deletions(-) diff --git a/slpkg/config.py b/slpkg/config.py index f3bda84b..fa07606f 100644 --- a/slpkg/config.py +++ b/slpkg/config.py @@ -30,13 +30,12 @@ from slpkg.utils import Utils from slpkg.__metadata__ import MetaData as _meta_ -class Config: +class Config(Utils): """Print or edit slpkg configuration file """ 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"] @@ -70,7 +69,7 @@ class Config: "EDITOR", "NOT_DOWNGRADE" ] - read_conf = self.utils.read_file(self.config_file) + read_conf = self.read_file(self.config_file) for line in read_conf.splitlines(): if not line.startswith("#") and line.split("=")[0] in conf_args: print(line) diff --git a/slpkg/desc.py b/slpkg/desc.py index d2d43caf..0c2b30dc 100644 --- a/slpkg/desc.py +++ b/slpkg/desc.py @@ -29,7 +29,7 @@ from slpkg.__metadata__ import MetaData as _meta_ from slpkg.sbo.greps import SBoGrep -class PkgDesc: +class PkgDesc(Utils): """Print package description from the repository """ def __init__(self, name, repo, paint): @@ -38,7 +38,6 @@ class PkgDesc: self.paint = paint self.meta = _meta_ self.msg = Msg() - self.utils = Utils() self.lib = "" self.color = { "red": self.meta.color["RED"], @@ -58,7 +57,7 @@ class PkgDesc: if self.repo == "sbo": description = SBoGrep(self.name).description() else: - PACKAGES_TXT = self.utils.read_file(self.lib) + PACKAGES_TXT = self.read_file(self.lib) for line in PACKAGES_TXT.splitlines(): if line.startswith(self.name + ":"): description += f"{line[len(self.name) + 2:]}\n" diff --git a/slpkg/downloader.py b/slpkg/downloader.py index f8fd1096..0a19e927 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -32,7 +32,7 @@ from slpkg.slack.slack_version import slack_ver from slpkg.__metadata__ import MetaData as _meta_ -class Download: +class Download(Utils): """Downloader manager. Slpkg use wget by default but support curl, aria2 and httpie """ @@ -57,7 +57,7 @@ class Download: dwn_count = 1 self._directory_prefix() for dwn in self.url: - self.file_name = Utils().fix_file_name(dwn.split("/")[-1]) + self.file_name = self.fix_file_name(dwn.split("/")[-1]) if dwn.startswith("file:///"): source_dir = dwn[7:-7].replace(slack_ver(), "") diff --git a/slpkg/init.py b/slpkg/init.py index d1a2b9fa..f45c322d 100644 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -35,7 +35,7 @@ from slpkg.slack.mirrors import mirrors from slpkg.slack.slack_version import slack_ver -class Initialization: +class Initialization(Utils): """Slpkg initialization start all from here. Create local package lists and update or upgrade these. """ @@ -685,8 +685,7 @@ class Initialization: for f in infiles: if os.path.isfile(f"{path}{f}"): # checking the encoding before read the file - utils = Utils() - code = utils.check_encoding(path, f) + code = self.check_encoding(path, f) with open(path + f, "r", encoding=code) as in_f: for line in in_f: out_f.write(line) diff --git a/slpkg/new_config.py b/slpkg/new_config.py index ce8cf1a4..a45b73b6 100644 --- a/slpkg/new_config.py +++ b/slpkg/new_config.py @@ -31,7 +31,7 @@ from slpkg.utils import Utils from slpkg.__metadata__ import MetaData as _meta_ -class NewConfig: +class NewConfig(Utils): """Manage .new configuration files """ def __init__(self): @@ -179,9 +179,9 @@ class NewConfig: """Print the differences between the two files """ if os.path.isfile(n[:-4]): - diff1 = Utils().read_file(n[:-4]).splitlines() + diff1 = self.read_file(n[:-4]).splitlines() if os.path.isfile(n): - diff2 = Utils().read_file(n).splitlines() + diff2 = self.read_file(n).splitlines() lines, ln, c = [], 0, 0 for a, b in itertools.izip_longest(diff1, diff2): ln += 1 @@ -208,9 +208,9 @@ class NewConfig: """Merge new file into old """ if os.path.isfile(n[:-4]): - old = Utils().read_file(n[:-4]).splitlines() + old = self.read_file(n[:-4]).splitlines() if os.path.isfile(n): - new = Utils().read_file(n).splitlines() + new = self.read_file(n).splitlines() with open(n[:-4], "w") as out: for l1, l2 in itertools.izip_longest(old, new): if l1 is None: diff --git a/slpkg/sbo/build_num.py b/slpkg/sbo/build_num.py index 57426f42..bfbb5033 100644 --- a/slpkg/sbo/build_num.py +++ b/slpkg/sbo/build_num.py @@ -29,7 +29,7 @@ from slpkg.url_read import URL from slpkg.__metadata__ import MetaData as _meta_ -class BuildNumber: +class BuildNumber(Utils): """Get build number from SlackBuild script """ def __init__(self, sbo_url, pkg): @@ -42,7 +42,7 @@ class BuildNumber: if self.sbo_url: SlackBuild = URL(f"{self.sbo_url}{self.pkg}.SlackBuild").reading() else: - SlackBuild = Utils().read_file(f"{self.meta.build_path}{self.pkg}/{self.pkg}.SlackBuild") + SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/{self.pkg}.SlackBuild") for line in SlackBuild.splitlines(): line = line.lstrip() if line.startswith("BUILD="): diff --git a/slpkg/sbo/greps.py b/slpkg/sbo/greps.py index 095a0089..e50e343c 100644 --- a/slpkg/sbo/greps.py +++ b/slpkg/sbo/greps.py @@ -26,7 +26,7 @@ from slpkg.utils import Utils from slpkg.__metadata__ import MetaData as _meta_ -class SBoGrep: +class SBoGrep(Utils): """Grab data from SLACKBUILDS.TXT file """ def __init__(self, name): @@ -45,7 +45,7 @@ class SBoGrep: self.sbo_txt = self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT" self.answer = ["y", "Y"] self.unst = ["UNSUPPORTED", "UNTESTED"] - self.SLACKBUILDS_TXT = Utils().read_file(self.sbo_txt) + self.SLACKBUILDS_TXT = self.read_file(self.sbo_txt) def _names_grabbing(self): """Generator that collecting all packages names diff --git a/slpkg/sbo/network.py b/slpkg/sbo/network.py index 97adcce7..a6a8b8a2 100644 --- a/slpkg/sbo/network.py +++ b/slpkg/sbo/network.py @@ -48,7 +48,7 @@ from slpkg.sbo.slack_find import slack_package from slpkg.slack.slack_version import slack_ver -class SBoNetwork(BlackList): +class SBoNetwork(BlackList, Utils): """View SBo site in terminal and also read, build or install packages """ @@ -135,7 +135,7 @@ class SBoNetwork(BlackList): lowercase """ if "--case-ins" in self.flag: - data_dict = Utils().case_sensitive(self.data) + data_dict = self.case_sensitive(self.data) for key, value in data_dict.items(): if key == self.name.lower(): self.name = value diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index bfeb841c..8a14929b 100644 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -50,7 +50,7 @@ from slpkg.slack.mirrors import mirrors from slpkg.slack.slack_version import slack_ver -class Patches(BlackList): +class Patches(BlackList, Utils): """Upgrade distribution from official Slackware mirrors """ def __init__(self, skip, flag): @@ -75,7 +75,6 @@ class Patches(BlackList): self.installed = [] self.comp_sum = [] self.uncomp_sum = [] - self.utils = Utils() self.msg.checking() if self.version == "stable": self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", @@ -111,7 +110,7 @@ class Patches(BlackList): if self.msg.answer() in ["y", "Y"]: Download(self.patch_path, self.dwn_links, repo="slack").start() - self.upgrade_all = list(self.utils.check_downloaded( + self.upgrade_all = list(self.check_downloaded( self.patch_path, self.upgrade_all)) self.upgrade() self.kernel() diff --git a/slpkg/tracking.py b/slpkg/tracking.py index 9af75eae..2546d22d 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -38,7 +38,7 @@ from slpkg.binary.search import search_pkg from slpkg.binary.dependency import Dependencies -class TrackingDeps(BlackList): +class TrackingDeps(BlackList, Utils): """View tree of dependencies and also highlight packages with color green if already installed and color red @@ -51,7 +51,6 @@ class TrackingDeps(BlackList): 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"] @@ -78,8 +77,8 @@ class TrackingDeps(BlackList): self.repositories() if self.find_pkg: self.dependencies_list.reverse() - self.requires = self.utils.dimensional_list(self.dependencies_list) - self.dependencies = self.utils.remove_dbs(self.requires) + self.requires = self.dimensional_list(self.dependencies_list) + self.dependencies = self.remove_dbs(self.requires) if self.dependencies == []: self.dependencies = ["No dependencies"] if "--graph=" in self.flag: @@ -130,9 +129,9 @@ class TrackingDeps(BlackList): if self.find_pkg: self.dependencies_list = Requires(self.flag).sbo(self.name) else: - PACKAGES_TXT = self.utils.read_file( + PACKAGES_TXT = self.read_file( f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT") - self.names = list(self.utils.package_name(PACKAGES_TXT)) + self.names = list(self.package_name(PACKAGES_TXT)) self.bin_case_insensitive() self.find_pkg = search_pkg(self.name, self.repo) if self.find_pkg: @@ -146,7 +145,7 @@ class TrackingDeps(BlackList): """ if "--case-ins" in self.flag: data = SBoGrep(name="").names() - data_dict = self.utils.case_sensitive(data) + data_dict = self.case_sensitive(data) for key, value in data_dict.items(): if key == self.name.lower(): self.name = value @@ -156,7 +155,7 @@ class TrackingDeps(BlackList): lowercase """ if "--case-ins" in self.flag: - data_dict = self.utils.case_sensitive(self.names) + data_dict = self.case_sensitive(self.names) for key, value in data_dict.items(): if key == self.name.lower(): self.name = value @@ -173,7 +172,7 @@ class TrackingDeps(BlackList): dep_path = f"{self.meta.log_path}dep/" logs = find_package("", dep_path) for log in logs: - deps = self.utils.read_file(f"{dep_path}{log}") + deps = self.read_file(f"{dep_path}{log}") for dep in deps.splitlines(): if pkg == dep: used.append(log) @@ -187,12 +186,12 @@ class TrackingDeps(BlackList): for dep in dependencies: deps = Requires(flag="").sbo(dep) if dep not in self.deps_dict.values(): - self.deps_dict[dep] = self.utils.dimensional_list(deps) + self.deps_dict[dep] = self.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] = self.utils.dimensional_list(deps) + self.deps_dict[dep] = self.dimensional_list(deps) def deps_used(self, pkg, used): """Create dependencies dictionary From 973744b5c410334b847eb6a3f9aaa87501507c02 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 15:40:12 +0100 Subject: [PATCH 06/13] Fixed tar commnad Signed-off-by: Dimitris Zlatanidis --- slackbuild/slpkg.SlackBuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index cbdb42bd..a8f54e26 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -68,7 +68,7 @@ mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION tar xvf $CWD/$PRGNAM-$VERSION.tar.gz || tar xvf $CWD/v$VERSION.tar.gz \ - || $CWD/$PRGNAM-$VERSION.tar.bz2 || unzip $CWD/$PRGNAM-$VERSION.zip \ + || tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 || unzip $CWD/$PRGNAM-$VERSION.zip \ || unzip $CWD/v$VERSION.zip cd $PRGNAM-$VERSION chown -R root:root . From bfb5022b8de7e4d6ea101d02e92658a225c4e588 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 15:42:49 +0100 Subject: [PATCH 07/13] Added hard dependencies --- slackbuild/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/slackbuild/README b/slackbuild/README index ef10d2b7..c0f6b174 100644 --- a/slackbuild/README +++ b/slackbuild/README @@ -4,6 +4,10 @@ computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. +Hard dependencies: + python3, python-urllib3 + + Optional dependencies: python3-pythondialog (for dialog box interface) pygraphviz (for drawing dependencies diagram) From 5c5515bec09df6b32796a85acc554115898423df Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 16:20:51 +0100 Subject: [PATCH 08/13] Updated utils and instances Signed-off-by: Dimitris Zlatanidis --- slpkg/binary/install.py | 21 ++++++++++----------- slpkg/binary/repo_init.py | 4 ++-- slpkg/binary/search.py | 6 ++++-- slpkg/checksum.py | 2 +- slpkg/pkg/find.py | 3 ++- slpkg/sbo/check.py | 3 ++- slpkg/sbo/search.py | 10 ++++++---- slpkg/sbo/slack_find.py | 3 ++- slpkg/security.py | 4 ++-- slpkg/slack/mirrors.py | 15 ++++++++------- slpkg/slack/slack_version.py | 3 ++- slpkg/slack/slackware_repo.py | 3 ++- slpkg/slpkg_update.py | 7 +++++++ slpkg/splitting.py | 4 ++++ 14 files changed, 54 insertions(+), 34 deletions(-) diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 66eb6642..39326960 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -48,7 +48,7 @@ from slpkg.binary.repo_init import RepoInit from slpkg.binary.dependency import Dependencies -class BinaryInstall(BlackList): +class BinaryInstall(BlackList, Utils): """Install binaries packages with all dependencies from repository """ @@ -65,7 +65,6 @@ class BinaryInstall(BlackList): self.yellow = _meta_.color['YELLOW'] self.endc = _meta_.color["ENDC"] self.msg = Msg() - self.utils = Utils() self.version = self.meta.slack_rel self.tmp_path = self.meta.slpkg_tmp_packages self.init_flags() @@ -163,9 +162,9 @@ class BinaryInstall(BlackList): self.msg.template(78) if "--download-only" in self.flag: raise SystemExit() - self.dep_install = list(self.utils.check_downloaded( + self.dep_install = list(self.check_downloaded( self.tmp_path, self.dep_install)) - self.install = list(self.utils.check_downloaded( + self.install = list(self.check_downloaded( self.tmp_path, self.install)) ins, upg = self.install_packages() self.msg.reference(ins, upg) @@ -192,8 +191,8 @@ class BinaryInstall(BlackList): lowercase """ if "--case-ins" in self.flag: - data = list(self.utils.package_name(self.PACKAGES_TXT)) - data_dict = self.utils.case_sensitive(data) + data = list(self.package_name(self.PACKAGES_TXT)) + data_dict = self.case_sensitive(data) for pkg in self.packages: index = self.packages.index(pkg) for key, value in data_dict.items(): @@ -204,7 +203,7 @@ class BinaryInstall(BlackList): """Update dependencies dictionary with all package """ for dep in self.dependencies: - deps = self.utils.dimensional_list(Dependencies( + deps = self.dimensional_list(Dependencies( self.repo, self.blacklist).binary( dep, self.flag)) self.deps_dict[dep] = deps @@ -214,7 +213,7 @@ class BinaryInstall(BlackList): or if added to install two or more times """ packages = [] - for mas in self.utils.remove_dbs(self.packages): + for mas in self.remove_dbs(self.packages): if mas not in self.dependencies: packages.append(mas) self.packages = packages @@ -268,11 +267,11 @@ class BinaryInstall(BlackList): self.msg.resolving() for dep in self.packages: dependencies = [] - dependencies = self.utils.dimensional_list(Dependencies( + dependencies = self.dimensional_list(Dependencies( self.repo, self.blacklist).binary(dep, self.flag)) requires += list(self._fix_deps_repos(dependencies)) - self.deps_dict[dep] = self.utils.remove_dbs(requires) - return self.utils.remove_dbs(requires) + self.deps_dict[dep] = self.remove_dbs(requires) + return self.remove_dbs(requires) def _fix_deps_repos(self, dependencies): """Fix store deps include in repository diff --git a/slpkg/binary/repo_init.py b/slpkg/binary/repo_init.py index be2b263d..aab1bead 100644 --- a/slpkg/binary/repo_init.py +++ b/slpkg/binary/repo_init.py @@ -30,7 +30,7 @@ from slpkg.slack.mirrors import mirrors from slpkg.slack.slack_version import slack_ver -class RepoInit: +class RepoInit(Utils): """Return PACKAGES.TXT and mirror by repository """ def __init__(self, repo): @@ -45,7 +45,7 @@ class RepoInit: else: self._init_custom() self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT" - PACKAGES_TXT = Utils().read_file(self.lib) + PACKAGES_TXT = self.read_file(self.lib) return PACKAGES_TXT, self.mirror def _init_custom(self): diff --git a/slpkg/binary/search.py b/slpkg/binary/search.py index 8fb3ef09..4ecf8abc 100644 --- a/slpkg/binary/search.py +++ b/slpkg/binary/search.py @@ -31,8 +31,10 @@ def search_pkg(name, repo): """Search if package exists in PACKAGES.TXT file and return the name. """ - PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") - names = list(Utils().package_name(PACKAGES_TXT)) + utils = Utils() + black = BlackList() + PACKAGES_TXT = utils.read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") + names = list(black.package_name(PACKAGES_TXT)) blacklist = list(BlackList().get_black()) if name in names and name not in blacklist: return name \ No newline at end of file diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 4004e46c..627a21db 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -46,7 +46,7 @@ def check_md5(pkg_md5, src_file): print(f"| Found: {md5s}") msg.template(78) print() - if not Msg().answer() in ["y", "Y"]: + if not msg.answer() in ["y", "Y"]: raise SystemExit() else: msg.template(78) diff --git a/slpkg/pkg/find.py b/slpkg/pkg/find.py index f70979f6..f4b85c85 100644 --- a/slpkg/pkg/find.py +++ b/slpkg/pkg/find.py @@ -30,9 +30,10 @@ from slpkg.splitting import split_package def searching(find_pkg, directory): """Find packages """ + black = BlackList() if os.path.isdir(directory): installed = os.listdir(directory) - blacklist = list(BlackList().get_black()) + blacklist = list(black.get_black()) if os.path.exists(directory): for pkg in installed: if (not pkg.startswith(".") and pkg.startswith(find_pkg) and diff --git a/slpkg/sbo/check.py b/slpkg/sbo/check.py index abbda538..89db8129 100644 --- a/slpkg/sbo/check.py +++ b/slpkg/sbo/check.py @@ -38,10 +38,11 @@ def sbo_upgrade(skip, flag): """Return packages for upgrade """ msg = Msg() + black = BlackList() msg.checking() upgrade_names = [] data = SBoGrep(name="").names() - blacklist = list(BlackList().get_black()) + blacklist = list(black.get_black()) for pkg in sbo_list(): name = split_package(pkg)[0] ver = split_package(pkg)[1] diff --git a/slpkg/sbo/search.py b/slpkg/sbo/search.py index 7d6472db..6ea43b70 100644 --- a/slpkg/sbo/search.py +++ b/slpkg/sbo/search.py @@ -34,10 +34,12 @@ def sbo_search_pkg(name): return url """ url = "" - repo = Repo().default_repository()["sbo"] - sbo_url = f"{repo}{slack_ver()}/" - SLACKBUILDS_TXT = Utils().read_file( - _meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT") + utils = Utils() + repo = Repo() + sbo = repo.default_repository()["sbo"] + sbo_url = f"{sbo}{slack_ver()}/" + SLACKBUILDS_TXT = utils.read_file( + f"{_meta_.lib_path}sbo_repo/SLACKBUILDS.TXT") for line in SLACKBUILDS_TXT.splitlines(): if line.startswith("SLACKBUILD LOCATION"): sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip() diff --git a/slpkg/sbo/slack_find.py b/slpkg/sbo/slack_find.py index 923965e5..0ae65320 100644 --- a/slpkg/sbo/slack_find.py +++ b/slpkg/sbo/slack_find.py @@ -33,6 +33,7 @@ from slpkg.pkg.find import find_package def slack_package(prgnam): """Return maximum binary Slackware package from output directory """ + msg = Msg() binaries, cache, binary = [], "0", "" for pkg in find_package(prgnam, _meta_.output): if pkg.startswith(prgnam) and pkg[:-4].endswith("_SBo"): @@ -43,6 +44,6 @@ def slack_package(prgnam): binary = bins cache = binary if not binary: - Msg().build_FAILED(prgnam) + msg.build_FAILED(prgnam) raise SystemExit(1) return ["".join(_meta_.output + binary)] diff --git a/slpkg/security.py b/slpkg/security.py index 5fe8fab5..ea2046ca 100644 --- a/slpkg/security.py +++ b/slpkg/security.py @@ -29,8 +29,8 @@ from slpkg.messages import Msg 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, msg = [], Msg() + packages, msg, utils = [], Msg(), Utils() + security_packages = utils.read_file("/etc/slpkg/pkg_security") for read in security_packages.splitlines(): read = read.lstrip() if not read.startswith("#"): diff --git a/slpkg/slack/mirrors.py b/slpkg/slack/mirrors.py index f5d70974..ffd057cb 100644 --- a/slpkg/slack/mirrors.py +++ b/slpkg/slack/mirrors.py @@ -34,20 +34,21 @@ def mirrors(name, location): """ rel = _meta_.slack_rel ver = slack_ver() - repo = Repo().slack() + repo = Repo() + slack = repo.slack() if _meta_.arch == "x86_64": if rel == "stable": - http = f"{repo}slackware64-{ver}/{location}{name}" + http = f"{slack}slackware64-{ver}/{location}{name}" else: - http = f"{repo}slackware64-{rel}/{location}{name}" + http = f"{slack}slackware64-{rel}/{location}{name}" elif _meta_.arch.startswith("arm"): if rel == "stable": - http = f"{repo}slackwarearm-{ver}/{location}{name}" + http = f"{slack}slackwarearm-{ver}/{location}{name}" else: - http = f"{repo}slackwarearm-{rel}/{location}{name}" + http = f"{slack}slackwarearm-{rel}/{location}{name}" else: if rel == "stable": - http = f"{repo}slackware-{ver}/{location}{name}" + http = f"{slack}slackware-{ver}/{location}{name}" else: - http = f"{repo}slackware-{rel}/{location}{name}" + http = f"{slack}slackware-{rel}/{location}{name}" return http diff --git a/slpkg/slack/slack_version.py b/slpkg/slack/slack_version.py index 5148dcb7..731a8e32 100644 --- a/slpkg/slack/slack_version.py +++ b/slpkg/slack/slack_version.py @@ -32,8 +32,9 @@ def slack_ver(): """ Open file and read Slackware version """ + utils = Utils() if _meta_.slackware_version in ["off", "OFF"]: - sv = Utils().read_file("/etc/slackware-version") + sv = utils.read_file("/etc/slackware-version") version = re.findall(r"\d+", sv) if len(sv) > 2: return (".".join(version[:2])) diff --git a/slpkg/slack/slackware_repo.py b/slpkg/slack/slackware_repo.py index 5b4fe2ff..65c6e899 100644 --- a/slpkg/slack/slackware_repo.py +++ b/slpkg/slack/slackware_repo.py @@ -31,9 +31,10 @@ from slpkg.__metadata__ import MetaData as _meta_ def slackware_repository(): """Return all official Slackware packages """ + utils = Utils() slack_repo, packages, names = [], [], [] slack_repo = repo_data( - Utils().read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"), + utils.read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"), "slack", "") for pkg in slack_repo[0]: names.append(split_package(pkg)[0]) diff --git a/slpkg/slpkg_update.py b/slpkg/slpkg_update.py index 349a9f00..056b427b 100644 --- a/slpkg/slpkg_update.py +++ b/slpkg/slpkg_update.py @@ -48,10 +48,12 @@ def it_self_update(): branch, _meta_.__all__)) version_data = URL(ver_link).reading() + for line in version_data.splitlines(): line = line.strip() if line.startswith("__version_info__"): __new_version__ = ".".join(re.findall(r"\d+", line)) + if __new_version__ > _meta_.__version__: if _meta_.default_answer in ["y", "Y"]: answer = _meta_.default_answer @@ -63,10 +65,12 @@ def it_self_update(): except EOFError: print() raise SystemExit(1) + if answer in ["y", "Y"]: print() # new line after answer else: raise SystemExit() + dwn_link = ["https://{0}.com/{1}/{2}/-/archive/" "{3}/{4}-{5}.tar.gz".format(repository, _meta_.__author__, @@ -74,8 +78,10 @@ def it_self_update(): __new_version__, _meta_.__all__, __new_version__)] + if not os.path.exists(_meta_.build_path): os.makedirs(_meta_.build_path) + Download(_meta_.build_path, dwn_link, repo="").start() os.chdir(_meta_.build_path) slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz" @@ -88,6 +94,7 @@ def it_self_update(): _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(f"\n{_meta_.__all__}: There is no new version, already used the last!\n") raise SystemExit() \ No newline at end of file diff --git a/slpkg/splitting.py b/slpkg/splitting.py index c89ec3b6..b164ffe4 100644 --- a/slpkg/splitting.py +++ b/slpkg/splitting.py @@ -29,14 +29,18 @@ def split_package(package): """ name = ver = arch = build = [] split = package.split("-") + if len(split) > 2: build = split[-1] build_a, build_b = "", "" build_a = build[:1] + if build[1:2].isdigit(): build_b = build[1:2] + build = build_a + build_b arch = split[-2] ver = split[-3] name = "-".join(split[:-3]) + return [name, ver, arch, build] From c29e6e10eadff616b79b2a50c58dc0aaaaa4b5e6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 16:28:07 +0100 Subject: [PATCH 09/13] Updated checksum tests Signed-off-by: Dimitris Zlatanidis --- tests/test_md5sum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_md5sum.py b/tests/test_md5sum.py index bf11cb01..1ce622c8 100644 --- a/tests/test_md5sum.py +++ b/tests/test_md5sum.py @@ -8,4 +8,4 @@ def test_md5_superuser(): def test_md5_security(): result = md5('slpkg/security.py') - assert result == "36c3a9213a27ab0b49e9c1bdd5bd2db6" + assert result == "eb8dbea4dec6d72353d30475670389f0" From f3b479ecd3af53d88a562464c3a09e5efe8a81d4 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 16:52:53 +0100 Subject: [PATCH 10/13] Updated searcing --- slpkg/binary/search.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slpkg/binary/search.py b/slpkg/binary/search.py index 4ecf8abc..849629b2 100644 --- a/slpkg/binary/search.py +++ b/slpkg/binary/search.py @@ -33,8 +33,8 @@ def search_pkg(name, repo): """ utils = Utils() black = BlackList() - PACKAGES_TXT = utils.read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") - names = list(black.package_name(PACKAGES_TXT)) - blacklist = list(BlackList().get_black()) - if name in names and name not in blacklist: + text = utils.read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") + PACKAGES_TXT = list(utils.package_name(text)) + blacklist = list(black.get_black()) + if name in PACKAGES_TXT and name not in blacklist: return name \ No newline at end of file From 055145f2bb7b5cd82d1f53eaeb5683b7ac76eb6e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 17 Feb 2020 17:14:24 +0100 Subject: [PATCH 11/13] Added tests Signed-off-by: Dimitris Zlatanidis --- tests/test_file_size.py | 2 ++ tests/test_md5sum.py | 4 ++++ tests/test_search_package.py | 19 +++++++++++++++++++ tests/test_units.py | 2 ++ tests/test_utils.py | 4 ++++ 5 files changed, 31 insertions(+) create mode 100644 tests/test_search_package.py diff --git a/tests/test_file_size.py b/tests/test_file_size.py index c6865c7f..a40d08dc 100644 --- a/tests/test_file_size.py +++ b/tests/test_file_size.py @@ -2,6 +2,8 @@ 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) diff --git a/tests/test_md5sum.py b/tests/test_md5sum.py index 1ce622c8..cf1590ff 100644 --- a/tests/test_md5sum.py +++ b/tests/test_md5sum.py @@ -2,10 +2,14 @@ from slpkg.md5sum import md5 def test_md5_superuser(): + """Testing checksum for superuser.py file + """ result = md5('slpkg/superuser.py') assert result == "c6a3576c247bda199c75b43540bfc3d7" def test_md5_security(): + """Testing checksum for security.py file + """ result = md5('slpkg/security.py') assert result == "eb8dbea4dec6d72353d30475670389f0" diff --git a/tests/test_search_package.py b/tests/test_search_package.py new file mode 100644 index 00000000..57e40a91 --- /dev/null +++ b/tests/test_search_package.py @@ -0,0 +1,19 @@ +from slpkg.binary.search import search_pkg +from slpkg.sbo.search import sbo_search_pkg + + +def test_search(): + """Testing found the name from binaries repos + """ + name = "vlc" + repo = "alien" + test = search_pkg(name, repo) + assert name == test + + +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 diff --git a/tests/test_units.py b/tests/test_units.py index 1cb43bdf..d1f0ef53 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -2,4 +2,6 @@ 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 diff --git a/tests/test_utils.py b/tests/test_utils.py index aa8ab3d7..540d578e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -2,12 +2,16 @@ 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) 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 From f621d96ffb453507efec5519768e75a33a029776 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 19 Feb 2020 15:21:12 +0100 Subject: [PATCH 12/13] Added settings for proxy server #124 Signed-off-by: Dimitris Zlatanidis --- conf/slpkg.conf | 6 +++++- slpkg/__metadata__.py | 6 +++--- slpkg/file_size.py | 5 ++++- slpkg/url_read.py | 5 ++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/conf/slpkg.conf b/conf/slpkg.conf index ad090e24..9bfde17f 100644 --- a/conf/slpkg.conf +++ b/conf/slpkg.conf @@ -122,4 +122,8 @@ EDITOR=nano # If you don't want slpkg downgrade packages, setting this variable to "on". # Warning: Possible failure building packages or running applications after # install. Default is "off". -NOT_DOWNGRADE=off \ No newline at end of file +NOT_DOWNGRADE=off + +# If you are working under a proxy server you need to set +# your proxy server here. Default is null. +HTTP_PROXY= \ No newline at end of file diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index da9254d5..33c7c1df 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -124,9 +124,9 @@ class MetaData: "DOWNDER_OPTIONS": "-c -N", "SLACKPKG_LOG": "on", "ONLY_INSTALLED": "off", - "PRG_BAR": "off", "EDITOR": "nano", - "NOT_DOWNGRADE": "off" + "NOT_DOWNGRADE": "off", + "HTTP_PROXY": "", } default_repositories = ["slack", "sbo", "rlw", "alien", "slacky", "conrad", @@ -172,9 +172,9 @@ class MetaData: downder_options = _conf_slpkg["DOWNDER_OPTIONS"] slackpkg_log = _conf_slpkg["SLACKPKG_LOG"] only_installed = _conf_slpkg["ONLY_INSTALLED"] - prg_bar = _conf_slpkg["PRG_BAR"] editor = _conf_slpkg["EDITOR"] not_downgrade = _conf_slpkg["NOT_DOWNGRADE"] + http_proxy = _conf_slpkg["HTTP_PROXY"] # SBo downloading sources path SBo_SOURCES = build_path + "_SOURCES/" diff --git a/slpkg/file_size.py b/slpkg/file_size.py index aef96023..b4595f8b 100644 --- a/slpkg/file_size.py +++ b/slpkg/file_size.py @@ -31,7 +31,10 @@ class FileSize: """ def __init__(self, registry): self.registry = registry - self.http = urllib3.PoolManager() + if self.meta.http_proxy: + self.http = urllib3.ProxyManager(self.meta.http_proxy) + else: + self.http = urllib3.PoolManager() def server(self): """Returns the size of remote files diff --git a/slpkg/url_read.py b/slpkg/url_read.py index e5632d0f..86e66ad0 100644 --- a/slpkg/url_read.py +++ b/slpkg/url_read.py @@ -35,7 +35,10 @@ class URL: self.meta = _meta_ self.red = _meta_.color["RED"] self.endc = _meta_.color["ENDC"] - self.http = urllib3.PoolManager() + if self.meta.http_proxy: + self.http = urllib3.ProxyManager(self.meta.http_proxy) + else: + self.http = urllib3.PoolManager() def reading(self): """Open url and read From d5dc8972385bfec3a77e470aca23b296cd58ecb4 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 21 Feb 2020 08:34:46 +0100 Subject: [PATCH 13/13] Updated for proxy server Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 +++- slpkg/config.py | 3 ++- slpkg/file_size.py | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 1c088b4d..dfb70ea0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,8 @@ -3.8.3 - 17/02/2020 +3.8.3 - 21/02/2020 BugFix: - Counting packages for binaries repositories +Added: +- Feature for proxy servers 3.8.2 - 15/02/2020 Fixed: diff --git a/slpkg/config.py b/slpkg/config.py index fa07606f..05f9cd42 100644 --- a/slpkg/config.py +++ b/slpkg/config.py @@ -67,7 +67,8 @@ class Config(Utils): "SLACKPKG_LOG", "ONLY_INSTALLED", "EDITOR", - "NOT_DOWNGRADE" + "NOT_DOWNGRADE", + "HTTP_PROXY", ] read_conf = self.read_file(self.config_file) for line in read_conf.splitlines(): diff --git a/slpkg/file_size.py b/slpkg/file_size.py index b4595f8b..33ff0b29 100644 --- a/slpkg/file_size.py +++ b/slpkg/file_size.py @@ -25,11 +25,14 @@ import os import urllib3 +from slpkg.__metadata__ import MetaData as _meta_ + class FileSize: """Check local or remote file size """ def __init__(self, registry): + self.meta = _meta_ self.registry = registry if self.meta.http_proxy: self.http = urllib3.ProxyManager(self.meta.http_proxy)