diff --git a/CONTRIBUTING b/CONTRIBUTING index 8bcefa67..f23faf4c 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -8,4 +8,4 @@ as important how a package is build. Small changes in the code each time more appreciated. Keep the style code applicable items. -Please ensure your changes work in Python 2.7.5+ +Please ensure your changes work in Python >= 3.7 diff --git a/ChangeLog.txt b/ChangeLog.txt index a359fcdd..f39f52fe 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,14 @@ -3.7.0 - 1/12/2019 +3.7.1 - 03/12/2019 +Updated: +- pythondialog dependency +- slackware mirrors +- pip installation method +- improved setup.py file for python3 +- print function for python3 format +Added: +- Dependency python requests replace bult-in python urllib + +3.7.0 - 01/12/2019 Updated: - Switch to python3 diff --git a/INSTALL.md b/INSTALL.md index 2de1a12d..38a74119 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -22,4 +22,5 @@ There are mainly 3 ways: 2. Download binary package from '`https://sourceforge.net/projects/slpkg/files/binary/`' and use Slackware command '`upgradepkg --install-new `' -3. Using pip: '`pip install https://gitlab.com/dslackw/slpkg/-/archive/3.7.0/slpkg-3.7.0.tar.gz`' +3. Using pip: '`pip3 install https://gitlab.com/dslackw/slpkg/-/archive/3.7.0/slpkg-3.7.0.tar.gz`' + or instead '`'python3 -m pip install`''. diff --git a/README.md b/README.md index ffcb2391..2ac6ee8e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# slpkg 3.7.0 +# slpkg 3.7.1 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 @@ -13,6 +13,17 @@ What makes slpkg to distinguish it from the other tools; The user friendliness i target as well as easy to understand and use, also use colors to highlight packages and display warning messages, etc. + + + + +#### Asciicast: + +[](https://asciinema.org/a/3uFNAOX8o16AmKKJDIvdezPBa) + + + + ##### Copyright Copyright 2014-2019 © Dimitris Zlatanidis. Slackware® is a Registered Trademark of Patrick Volkerding. Linux is a Registered Trademark of Linus Torvalds. diff --git a/bin/slpkg b/bin/slpkg index 86e5f175..d00add3c 100755 --- a/bin/slpkg +++ b/bin/slpkg @@ -40,5 +40,5 @@ if __name__ == "__main__": s_user() main() except KeyboardInterrupt: - print("") + print() raise SystemExit() diff --git a/conf/slackware-mirrors b/conf/slackware-mirrors index 758b607f..a4a60e49 100644 --- a/conf/slackware-mirrors +++ b/conf/slackware-mirrors @@ -32,8 +32,7 @@ # ---------------------------------------------------------------------------- # # -# Last Updated: Tue Jan 15 14:54:01 UTC 2019 -# +# Last Updated: Mon Dec 2 14:54:02 UTC 2019 # Available https mirrors: # # bg https://mirrors.linux-bulgaria.org/slackware/ @@ -48,7 +47,6 @@ # de https://mirror.netcologne.de/slackware/ # dk https://mirrors.dotsrc.org/slackware/ # ec https://mirror.cedia.org.ec/slackware/ -# fr https://mirrors.phx.ms/slackware/ # gb https://lon.mirror.rackspace.com/slackware/ # gb https://mirror.bytemark.co.uk/slackware/ # gb https://www.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/ @@ -85,6 +83,7 @@ # us https://slackware.absolutehosting.net/pub/slackware/ # # +# # Available http mirrors: # # au http://ftp.swin.edu.au/slackware/ @@ -97,7 +96,6 @@ # bg http://x.ultranet.biz/slackware/ # br http://ftp.slackware-brasil.com.br/ # br http://linorg.usp.br/slackware/ -# br http://slackmirror.cbpf.br/pub/slackware/ # by http://mirror.datacenter.by/pub/slackware/ # cz http://ftp.linux.cz/pub/linux/slackware/ # de http://download.dlackware.com/slackware/ @@ -123,8 +121,10 @@ # ph http://mirror.rise.ph/slackware/ # pl http://mirror.onet.pl/pub/mirrors/slackware/ # ru http://slackware.tsu.ru/slackware/ +# sg http://download.nus.edu.sg/mirror/slackware/ # tr http://ftp.linux.org.tr/slackware/ # tw http://ftp.isu.edu.tw/pub/Linux/Slackware/ +# ua http://slackware.ip-connect.info/ # us http://ftp.gtlib.gatech.edu/pub/slackware/ # us http://ftp.slackware.com/pub/slackware/ # us http://mirror.cs.princeton.edu/pub/mirrors/slackware/ @@ -135,76 +135,3 @@ # za http://ftp.is.co.za/mirror/ftp.slackware.com/pub/ # za http://ftp.wa.co.za/pub/slackware/ # za http://slackware.mirror.ac.za/ -# -# -# Available ftp mirrors: -# -# au ftp://ftp.swin.edu.au/slackware/ -# au ftp://mirror.as24220.net/pub/slackware/slackware64-14.2/ -# au ftp://mirror.internode.on.net/pub/slackware/ -# au ftp://syd.mirror.rackspace.com/slackware/ -# bg ftp://mirrors.netix.net/slackware/ -# bg ftp://mirrors.slackware.bg/slackware/ -# bg ftp://mirrors.unixsol.org/slackware/ -# bg ftp://slackware.telecoms.bg/slackware/ -# br ftp://ftp.slackware-brasil.com.br/ -# br ftp://linorg.usp.br/slackware/ -# by ftp://mirror.datacenter.by/pub/slackware/ -# ca ftp://mirror.csclub.uwaterloo.ca/slackware/ -# ca ftp://mirror.its.dal.ca/slackware/ -# ca ftp://slackware.freemirror.org/slackware/ -# cr ftp://mirrors.ucr.ac.cr/slackware/pub/slackware/ -# cz ftp://ftp.linux.cz/pub/linux/slackware/ -# de ftp://ftp.tu-chemnitz.de/pub/linux/slackware/ -# de ftp://ftp6.gwdg.de/pub/linux/slackware/ -# de ftp://linux.rz.rub.de/slackware/ -# de ftp://mirror.de.leaseweb.net/slackware/ -# de ftp://mirror.netcologne.de/slackware/ -# de ftp://mirrors.nav.ro/slackware/ -# dk ftp://mirrors.dotsrc.org/slackware/ -# ec ftp://mirror.cedia.org.ec/slackware/ -# gb ftp://ftp.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/ -# gb ftp://lon.mirror.rackspace.com/slackware/ -# gb ftp://mirror.bytemark.co.uk/slackware/ -# gb ftp://slackware.uk/slackware/ -# gr ftp://ftp.cc.uoc.gr/mirrors/linux/slackware/ -# gr ftp://ftp.ntua.gr/pub/linux/slackware/ -# gr ftp://ftp.otenet.gr/pub/linux/slackware/ -# hk ftp://hkg.mirror.rackspace.com/slackware/ -# hr ftp://mirror.slackware.hr/slackware/ -# jp ftp://ftp.kddilabs.jp/Linux/distributions/Slackware/ -# jp ftp://ftp.nara.wide.ad.jp/pub/Linux/slackware/ -# jp ftp://ftp.riken.jp/Linux/slackware/ -# nc ftp://mirror.lagoon.nc/pub/slackware/ -# nl ftp://ftp.nluug.nl/pub/os/Linux/distr/slackware/ -# nl ftp://mirror.nl.leaseweb.net/slackware/ -# no ftp://ftp.slackware.no/slackware/ -# nz ftp://ftp.slackware.org.nz/slackware/ -# ph ftp://mirror.rise.ph/slackware/ -# pl ftp://ftp.slackware.pl/pub/slackware/ -# pl ftp://mirror.onet.pl/pub/mirrors/slackware/ -# pl ftp://sunsite.icm.edu.pl/pub/Linux/slackware/ -# pt ftp://ftp.rnl.tecnico.ulisboa.pt/pub/slackware/ -# ru ftp://mirror.yandex.ru/slackware/ -# ru ftp://slackware.tsu.ru/slackware/ -# se ftp://ftp.acc.umu.se/mirror/slackware.com/ -# tr ftp://ftp.linux.org.tr/slackware/ -# tw ftp://ftp.yzu.edu.tw/Linux/Slackware/ -# ua ftp://ifconfig.com.ua/pub/Mirror/slackware/ -# ua ftp://mirrors.nix.org.ua/linux/slackware/ -# us ftp://dfw.mirror.rackspace.com/slackware/ -# us ftp://ftp.gtlib.gatech.edu/pub/slackware -# us ftp://ftp.lug.udel.edu/pub/slackware/ -# us ftp://ftp.slackware.com/pub/slackware/ -# us ftp://ftp.ussg.indiana.edu/linux/slackware/ -# us ftp://mirror.cs.princeton.edu/pub/mirrors/slackware/ -# us ftp://mirror.slackbuilds.org/pub/slackware/ -# us ftp://mirror.us.leaseweb.net/slackware/ -# us ftp://mirrors.syringanetworks.net/slackware/ -# us ftp://mirrors.xmission.com/slackware/ -# us ftp://slackware.absolutehosting.net/pub/slackware/ -# us ftp://slackware.cs.utah.edu/slackware/ -# us ftp://slackware.mirrors.tds.net/pub/slackware -# za ftp://ftp.is.co.za/mirror/ftp.slackware.com/pub/ -# za ftp://ftp.wa.co.za/pub/slackware/ -# za ftp://slackware.mirror.ac.za/ diff --git a/requirements.txt b/requirements.txt index d6717b83..2edcd05f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,6 @@ # httpie (alternative downloader) # pygraphviz >= 1.3.1 (drawing dependencies diagram) # perl 5 language and graph-easy >= 0.75 (drawing dependencies ascii diagram) -# python3-pythondialog >= 3.3.0 (Python interface to the UNIX dialog utility) +# python3-pythondialog >= 3.5.0 (Python interface to the UNIX dialog utility) + +python-requests >= 2.22.0 diff --git a/setup.py b/setup.py index 8b3d55f1..25e90606 100755 --- a/setup.py +++ b/setup.py @@ -34,12 +34,14 @@ try: except ImportError: from distutils.core import setup -INSTALLATION_REQUIREMENTS = [] -DOCS_REQUIREMENTS = [] -TESTS_REQUIREMENTS = [] -OPTIONAL_REQUIREMENTS = [ - "python3-pythondialog >= 3.3.0", - "pygraphviz >= 1.3.1" +docs_requires = [] +tests_requires = [] +install_requires = [ + "requests>=2.22.0" +] +optional_requires = [ + "pythondialog>=3.5.0", + "pygraphviz>=1.3.1" ] # Non-Python/non-PyPI optional dependencies: @@ -47,6 +49,7 @@ OPTIONAL_REQUIREMENTS = [ def print_logo(): + """print slpkg logo""" if "install" not in sys.argv: logo_fname = os.path.join(os.path.dirname(__file__), 'logo.txt') with open(logo_fname, 'rb') as f: @@ -65,6 +68,7 @@ setup( scripts=["bin/slpkg"], version=_meta_.__version__, description="Package manager for Slackware installations", + long_description=open("README.md").read(), keywords=["slackware", "slpkg", "upgrade", "install", "remove", "view", "slackpkg", "tool", "build"], author=_meta_.__author__, @@ -74,11 +78,11 @@ setup( data_files=[("man/man8", ["man/slpkg.8"]), ("/etc/bash_completion.d", ["conf/slpkg.bash-completion"]), ("/etc/fish/completions", ["conf/slpkg.fish"])], - install_requires=INSTALLATION_REQUIREMENTS, + install_requires=install_requires, extras_require={ - "optional": OPTIONAL_REQUIREMENTS, - "docs": DOCS_REQUIREMENTS, - "tests": TESTS_REQUIREMENTS, + "optional": optional_requires, + "docs": docs_requires, + "tests": tests_requires, }, classifiers=[ "Development Status :: 5 - Production/Stable", @@ -86,14 +90,18 @@ setup( "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: POSIX :: Linux", "Operating System :: Unix", + "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Unix Shell", "Topic :: Software Development :: Build Tools", "Topic :: System :: Archiving :: Packaging", "Topic :: System :: Software Distribution", + "Topic :: System :: Installation/Setup", + "Topic :: System :: Systems Administration", + "Topic :: System :: Software Distribution", "Topic :: Utilities"], - long_description=open("README.md").read() - ) + python_requires=">=3.7" +) # Install configuration files with pip. if "install" in sys.argv: diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index 5e3c35e5..24188dca 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -78,7 +78,7 @@ class MetaData(object): __all__ = "slpkg" __author__ = "dslackw" - __version_info__ = (3, 7, 0) + __version_info__ = (3, 7, 1) __version__ = "{0}.{1}.{2}".format(*__version_info__) __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com" diff --git a/slpkg/auto_pkg.py b/slpkg/auto_pkg.py index 93520747..fc1c160f 100644 --- a/slpkg/auto_pkg.py +++ b/slpkg/auto_pkg.py @@ -49,7 +49,7 @@ class Auto(object): print("\nDetected Slackware binary package for installation:\n") for pkg in self.packages: print(" " + pkg.split("/")[-1]) - print("") + print() self.msg.template(78) print("| Choose a Slackware command:") self.msg.template(78) @@ -62,7 +62,7 @@ class Auto(object): try: self.choice = input(" > ") except EOFError: - print("") + print() raise SystemExit() if self.choice in self.commands.keys(): print(" \x1b[1A{0}{1}{2}\n\n".format( diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 4db3605d..f0d1060c 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -140,7 +140,7 @@ class BinaryInstall(object): print("After this process, {0} {1} of additional disk " "space will be used.{2}".format(size[1], unit[1], self.meta.color["ENDC"])) - print("") + print() self.if_all_installed() if self.msg.answer() in ["y", "Y"]: for inst, dwn in zip(self.dep_install + self.install, diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 1675985a..d1d13ade 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -60,7 +60,7 @@ class BlackList(object): self.meta.color["ENDC"])) self.quit = True if self.quit: - print("") # new line at exit + print() # new line at exit def add(self, pkgs): """Add blacklist packages if not exist @@ -77,7 +77,7 @@ class BlackList(object): self.quit = True black_conf.close() if self.quit: - print("") # new line at exit + print() # new line at exit def remove(self, pkgs): """Remove packages from blacklist @@ -93,7 +93,7 @@ class BlackList(object): self.quit = True remove.close() if self.quit: - print("") # new line at exit + print() # new line at exit def packages(self, pkgs, repo): """Return packages in blacklist or by repository diff --git a/slpkg/checks.py b/slpkg/checks.py index 60b187f2..b517e507 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -63,7 +63,7 @@ class Updates(object): def status_bar(self): """Top view bar status """ - print("") + print() self.msg.template(78) print("| Repository Status") self.msg.template(78) diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 685a91c0..ea82edad 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -31,7 +31,7 @@ def check_md5(pkg_md5, src_file): """MD5 Checksum """ if _meta_.checkmd5 in ["on", "ON"]: - print("") + print() md5s = md5(src_file) if pkg_md5 != md5s: Msg().template(78) @@ -42,7 +42,7 @@ def check_md5(pkg_md5, src_file): print("| Expected: {0}".format(pkg_md5)) print("| Found: {0}".format(md5s)) Msg().template(78) - print("") + print() if not Msg().answer() in ["y", "Y"]: raise SystemExit() else: @@ -51,4 +51,4 @@ def check_md5(pkg_md5, src_file): src_file.split("/")[-1], _meta_.color["GREEN"], _meta_.color["ENDC"])) Msg().template(78) - print("") # new line after pass checksum + print() # new line after pass checksum diff --git a/slpkg/config.py b/slpkg/config.py index 744f1b4c..b0f0a048 100644 --- a/slpkg/config.py +++ b/slpkg/config.py @@ -40,7 +40,7 @@ class Config(object): def view(self): """View slpkg config file """ - print("") # new line at start + print() # new line at start conf_args = [ "RELEASE", "SLACKWARE_VERSION", @@ -74,7 +74,7 @@ class Config(object): else: print("{0}{1}{2}".format(self.meta.color["CYAN"], line, self.meta.color["ENDC"])) - print("") # new line at end + print() # new line at end def edit(self): """Edit configuration file diff --git a/slpkg/desc.py b/slpkg/desc.py index 73f78946..f5042e1c 100644 --- a/slpkg/desc.py +++ b/slpkg/desc.py @@ -56,7 +56,7 @@ class PkgDesc(object): def view(self): """Print package description by repository """ - print("") # new line at start + print() # new line at start description, count = "", 0 if self.repo == "sbo": description = SBoGrep(self.name).description() @@ -75,4 +75,4 @@ class PkgDesc(object): self.msg.pkg_not_found("", self.name, "No matching", "\n") raise SystemExit(1) if description and self.repo == "sbo": - print("") + print() diff --git a/slpkg/downloader.py b/slpkg/downloader.py index d15d0079..58a0a9d5 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -100,13 +100,13 @@ class Download(object): """Check if file downloaded """ if not os.path.isfile(self.path + self.file_name): - print("") + print() self.msg.template(78) print("| Download '{0}' file [ {1}FAILED{2} ]".format( self.file_name, self.meta.color["RED"], self.meta.color["ENDC"])) self.msg.template(78) - print("") + print() if not self.msg.answer() in ["y", "Y"]: raise SystemExit() @@ -121,7 +121,7 @@ class Download(object): print("| '{0}' need to go ahead downloading".format( certificate[:23].strip())) self.msg.template(78) - print("") + print() self.downder_options += certificate if not self.msg.answer() in ["y", "Y"]: raise SystemExit() diff --git a/slpkg/file_size.py b/slpkg/file_size.py index f5b80859..5359e0b9 100644 --- a/slpkg/file_size.py +++ b/slpkg/file_size.py @@ -23,8 +23,7 @@ import os -import urllib -from urllib.request import urlopen +import requests class FileSize(object): @@ -37,10 +36,9 @@ class FileSize(object): """Returns the size of remote files """ try: - tar = urlopen(self.registry) - meta = tar.info() - return int(meta.get_all("Content-Length")[0]) - except (urllib.error.URLError, IndexError): + r = requests.head(self.registry) + return int(r.headers["Content-Length"]) + except (requests.exceptions.Timeout): return " " def local(self): diff --git a/slpkg/health.py b/slpkg/health.py index 011cb84e..b8e011c5 100644 --- a/slpkg/health.py +++ b/slpkg/health.py @@ -62,7 +62,7 @@ class PackageHealth(object): elif not self.mode: print(line) except IOError: - print("") + print() raise SystemExit() def test(self): @@ -87,7 +87,7 @@ class PackageHealth(object): def results(self): """Print results """ - print("") + print() per = int(round((float(self.cf) / (self.cf + self.cn)) * 100)) if per > 90: color = self.meta.color["GREEN"] diff --git a/slpkg/init.py b/slpkg/init.py index 20ce4320..4386703d 100644 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -784,7 +784,7 @@ class Update(object): print(self.done, end="") else: print(self.error, end="") - print("") # new line at end + print() # new line at end raise SystemExit() diff --git a/slpkg/messages.py b/slpkg/messages.py index ac59f1e9..844c3155 100644 --- a/slpkg/messages.py +++ b/slpkg/messages.py @@ -59,7 +59,7 @@ class Msg(object): "directory or read the README file".format( self.meta.color["CYAN"], self.meta.color["ENDC"])) self.template(78) - print("") # new line at end + print() # new line at end def template(self, max_len): """Print template @@ -126,14 +126,14 @@ class Msg(object): try: answer = input("Would you like to continue [y/N]? ") except EOFError: - print("") + print() raise SystemExit() return answer def security_pkg(self, pkg): """Warning message for some special reasons """ - print("") + print() self.template(78) print("| {0}{1}*** WARNING ***{2}").format( " " * 27, self.meta.color["RED"], self.meta.color["ENDC"]) @@ -142,7 +142,7 @@ class Msg(object): "| the README file. You can use the command " "'slpkg -n {1}'").format(pkg, pkg) self.template(78) - print("") + print() def reference(self, install, upgrade): """Reference list with packages installed @@ -159,7 +159,7 @@ class Msg(object): if installed: print("| Package {0} installed successfully".format(installed)) self.template(78) - print("") + print() def matching(self, packages): """Message for matching packages diff --git a/slpkg/new_config.py b/slpkg/new_config.py index 97382316..e19741ff 100644 --- a/slpkg/new_config.py +++ b/slpkg/new_config.py @@ -52,7 +52,7 @@ class NewConfig(object): self.find_new() for n in self.news: print("{0}".format(n)) - print("") + print() self.msg.template(78) print("| Installed {0} new configuration files:".format( len(self.news))) @@ -90,9 +90,9 @@ class NewConfig(object): try: choose = input("\nWhat would you like to do [K/O/R/P/Q]? ") except EOFError: - print("") + print() raise SystemExit() - print("") + print() if choose in ("K", "k"): self.keep() elif choose in ("O", "o"): @@ -114,7 +114,7 @@ class NewConfig(object): """ for n in self.news: self._remove(n) - print("") + print() def prompt(self): """Select file @@ -127,22 +127,22 @@ class NewConfig(object): self.red, self.endc, self.br, self.red, self.endc, self.br, self.red, self.endc, self.br, self.red, self.endc, self.br)) self.msg.template(78) - print("") + print() self.i = 0 try: while self.i < len(self.news): self.question(self.news[self.i]) self.i += 1 except EOFError: - print("") + print() raise SystemExit() def question(self, n): """Choose what do to file by file """ - print("") + print() prompt_ask = input("{0} [K/O/R/D/M/Q]? ".format(n)) - print("") + print() if prompt_ask in ("K", "k"): self.keep() elif prompt_ask in ("O", "o"): diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py index fc469c61..ffadc56d 100644 --- a/slpkg/pkg/manager.py +++ b/slpkg/pkg/manager.py @@ -99,7 +99,7 @@ class PackageManager(object): dependencies, rmv_list = [], [] self.removed = self._view_removed() if not self.removed: - print("") # new line at end + print() # new line at end else: msg = "package" if len(self.removed) > 1: @@ -112,7 +112,7 @@ class PackageManager(object): "\nAre you sure to remove {0} {1} [y/N]? ".format( str(len(self.removed)), msg)) except EOFError: - print("") # new line at exit + print() # new line at exit raise SystemExit() if remove_pkg in ["y", "Y"]: self._check_if_used(self.binary) @@ -147,9 +147,9 @@ class PackageManager(object): remove_dep = input( "\nRemove dependencies (maybe used by " "other packages) [y/N]? ") - print("") + print() except EOFError: - print("") # new line at exit + print() # new line at exit raise SystemExit() return remove_dep @@ -276,7 +276,7 @@ class PackageManager(object): dependencies.append("-".join(d.split("-")[:-1])) self.meta.remove_deps_answer = "y" else: - print("") # new line at start + print() # new line at start self.msg.template(78) print("| Found dependencies for the package {0}:".format( package)) @@ -339,7 +339,7 @@ class PackageManager(object): try: self.skip = input(" > ").split() except EOFError: - print("") + print() raise SystemExit() for s in self.skip: if s in self.removed: @@ -388,7 +388,7 @@ class PackageManager(object): def _reference_rmvs(self, removes): """Prints all removed packages """ - print("") + print() self.msg.template(78) msg_pkg = "package" if len(removes) > 1: @@ -401,7 +401,7 @@ class PackageManager(object): else: print("| Package {0} not found".format(pkg)) self.msg.template(78) - print("") # new line at end + print() # new line at end def find(self, flag): """Find installed Slackware packages @@ -498,7 +498,7 @@ class PackageManager(object): r = self.list_lib(repo) pkg_list = self.list_greps(repo, r)[0] all_installed_names = self.list_of_installed(repo, name) - print("") + print() for pkg in sorted(pkg_list): pkg = self._splitting_packages(pkg, repo, name) if installed: @@ -525,13 +525,13 @@ class PackageManager(object): self.meta.color["ENDC"])) if read in ["Q", "q"]: break - print("") # new line after page + print() # new line after page page += row else: print(pkg) - print("") # new line at end - except EOFError: - print("") # new line at exit + print() # new line at end + except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError): + print() # new line at exit raise SystemExit() def _splitting_packages(self, pkg, repo, name): diff --git a/slpkg/repoinfo.py b/slpkg/repoinfo.py index e98c4066..773092ff 100644 --- a/slpkg/repoinfo.py +++ b/slpkg/repoinfo.py @@ -98,10 +98,10 @@ class RepoInfo(object): self.form["Number of packages:"] = sum_sbo_pkgs self.form["Status:"] = status self.form["Last updated:"] = last_upd - print("") + print() for key, value in sorted(self.form.items()): print(self.meta.color["GREY"] + key + self.meta.color["ENDC"], value) - print("") + print() raise SystemExit() def repository_data(self, repo): diff --git a/slpkg/repolist.py b/slpkg/repolist.py index aa74dce8..8fcb2aa6 100644 --- a/slpkg/repolist.py +++ b/slpkg/repolist.py @@ -41,7 +41,7 @@ class RepoList(object): """View or enabled or disabled repositories """ def_cnt, cus_cnt = 0, 0 - print("") + print() self.msg.template(78) print("{0}{1}{2}{3}{4}{5}{6}".format( "| Repo id", " " * 2, diff --git a/slpkg/sbo/network.py b/slpkg/sbo/network.py index e9dcaec6..5c432320 100644 --- a/slpkg/sbo/network.py +++ b/slpkg/sbo/network.py @@ -174,7 +174,7 @@ class SBoNetwork(object): self.choice = input("{0}{1}{2}".format(self.grey, message, self.endc)) except EOFError: - print("") + print() raise SystemExit() try: print("{0}\x1b[1A{1}{2}{3}\n".format( @@ -261,7 +261,7 @@ class SBoNetwork(object): br1 = "(" br2 = ")" fix_sp = "" - print("") # new line at start + print() # new line at start self.msg.template(78) print("| {0}{1}SlackBuilds Repository{2}".format(" " * 28, self.grey, self.endc)) @@ -365,7 +365,7 @@ class SBoNetwork(object): pkg_security([self.name]) self.error_uns() if self.FAULT: - print("") + print() self.msg.template(78) print("| Package {0} {1} {2} {3}".format(self.prgnam, self.red, self.FAULT, self.endc)) diff --git a/slpkg/sbo/queue.py b/slpkg/sbo/queue.py index eef9f5a5..7ae2de2d 100644 --- a/slpkg/sbo/queue.py +++ b/slpkg/sbo/queue.py @@ -86,7 +86,7 @@ class QueuePkgs(object): self.meta.color["ENDC"])) self.quit = True if self.quit: - print("") # new line at exit + print() # new line at exit def add(self, pkgs): """Add packages in queue if not exist @@ -108,7 +108,7 @@ class QueuePkgs(object): self.quit = True queue.close() if self.quit: - print("") # new line at exit + print() # new line at exit def remove(self, pkgs): """Remove packages from queue @@ -124,7 +124,7 @@ class QueuePkgs(object): self.quit = True queue.close() if self.quit: - print("") # new line at exit + print() # new line at exit def build(self): """Build packages from queue @@ -158,7 +158,7 @@ class QueuePkgs(object): """ packages = self.packages() if packages: - print("") # new line at start + print() # new line at start for pkg in packages: ver = SBoGrep(pkg).version() prgnam = "{0}-{1}".format(pkg, ver) diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index f052ed7c..c53bf385 100644 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -112,7 +112,7 @@ class Patches(object): print("After this process, {0} {1} of additional disk space " "will be used.{2}".format(size[1], unit[1], self.meta.color["ENDC"])) - print("") + print() if self.msg.answer() in ["y", "Y"]: Download(self.patch_path, self.dwn_links, repo="slack").start() @@ -121,9 +121,12 @@ class Patches(object): self.upgrade() self.kernel() if self.meta.slackpkg_log in ["on", "ON"]: + # update the slackpkg ChanheLog.txt file self.slackpkg_update() self.msg.reference(self.installed, self.upgraded) + # delete the downloaded packages delete_package(self.patch_path, self.upgrade_all) + # update the packages lists self.update_lists() else: slack_arch = "" @@ -238,7 +241,7 @@ class Patches(object): if self.meta.default_answer in ["y", "Y"]: answer = self.meta.default_answer else: - print("") + print() self.msg.template(78) print("| {0}*** HIGHLY recommended reinstall boot loader " "***{1}".format(self.meta.color["RED"], @@ -247,9 +250,9 @@ class Patches(object): self.msg.template(78) try: answer = input("\nThe kernel has been upgraded, " - "reinstall boot loader [L/E/G]? ") + "reinstall boot loader [L/E/G]? ") except EOFError: - print("") + print() raise SystemExit() if answer in ["L"]: subprocess.call("lilo", shell=True) @@ -266,6 +269,8 @@ class Patches(object): """This replace slackpkg ChangeLog.txt file with new from Slackware official mirrors after update distribution. """ + print(mirrors("ChangeLog.txt", "")) + NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading() if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt.old"): os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt.old") @@ -275,7 +280,6 @@ class Patches(object): os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt") with open(self.meta.slackpkg_lib_path + "ChangeLog.txt", "w") as log: log.write(NEW_ChangeLog_txt) - log.close() def update_lists(self): """Update packages list and ChangeLog.txt file after diff --git a/slpkg/slpkg_update.py b/slpkg/slpkg_update.py index fa2f9987..bbf585e9 100644 --- a/slpkg/slpkg_update.py +++ b/slpkg/slpkg_update.py @@ -61,10 +61,10 @@ def it_self_update(): try: answer = input("Would you like to upgrade [y/N]? ") except EOFError: - print("") + print() raise SystemExit() if answer in ["y", "Y"]: - print("") # new line after answer + print() # new line after answer else: raise SystemExit() dwn_link = ["https://{0}.com/{1}/{2}/-/archive/" diff --git a/slpkg/status_deps.py b/slpkg/status_deps.py index a275f68f..88ea6d91 100644 --- a/slpkg/status_deps.py +++ b/slpkg/status_deps.py @@ -85,7 +85,7 @@ class DependenciesStatus(object): """Show dependencies status """ self.data() - print("") + print() self.msg.template(78) print("| {0}{1}{2}".format("Dependencies", " " * 20, "Packages")) self.msg.template(78) diff --git a/slpkg/tracking.py b/slpkg/tracking.py index fb090b84..e41ad82a 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -79,7 +79,7 @@ class TrackingDeps(object): self.deps_tree() self.msg.done() pkg_len = len(self.name) + 24 - print("") # new line at start + print() # new line at start self.msg.template(pkg_len) print("| Package {0}{1}{2} dependencies :".format( self.cyan, self.name, self.endc)) @@ -114,7 +114,7 @@ class TrackingDeps(object): if self.meta.use_colors in ["off", "OFF"]: print("\n * = Installed\n") else: - print("") # new line at end + print() # new line at end if "--graph=" in self.flag: self.graph() else: diff --git a/slpkg/upgrade_checklist.py b/slpkg/upgrade_checklist.py index 34af366f..cb171057 100644 --- a/slpkg/upgrade_checklist.py +++ b/slpkg/upgrade_checklist.py @@ -54,5 +54,5 @@ def choose_upg(packages): selected_packages.append(name) if not selected_packages: raise SystemExit() - print("") + print() return selected_packages diff --git a/slpkg/url_read.py b/slpkg/url_read.py index 8ce04e35..205b8a75 100644 --- a/slpkg/url_read.py +++ b/slpkg/url_read.py @@ -22,9 +22,7 @@ # along with this program. If not, see . -# import os -import urllib -from urllib.request import urlopen +import requests from slpkg.__metadata__ import MetaData as _meta_ @@ -40,27 +38,9 @@ class URL(object): """Open url and read """ try: - ''' - # testing proxy - proxies = {} - try: - proxies["http_proxy"] = os.environ['http_proxy'] - except KeyError: - pass - try: - proxies["https_proxy"] = os.environ['https_proxy'] - except KeyError: - pass - - if len(proxies) != 0: - proxy = urllib2.ProxyHandler(proxies) - opener = urllib2.build_opener(proxy) - urllib2.install_opener(opener) - # end testing - ''' - f = urlopen(self.link) - return f.read().decode("utf-8") - except (urllib.error.URLError, ValueError): + f = requests.get(self.link) + return f.text + except (requests.exceptions.Timeout): print("\n{0}Can't read the file '{1}'{2}".format( self.meta.color["RED"], self.link.split("/")[-1], self.meta.color["ENDC"]))