From f7d557c8691aabfd7a54da41782650c021102dc3 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 8 Dec 2019 19:47:06 +0100 Subject: [PATCH 1/5] Updated ChangeLog file Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 64958a0c..6e5d55a0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +3.7.3 - 06/12/2019 +Fixed: +- code style to python3 compatibility + 3.7.2 - 06/12/2019 Fixed: - Bugfix handle requests raise ConnectionError From c130631404305920662b42bc0ca66d163065c14e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 9 Dec 2019 11:22:42 +0100 Subject: [PATCH 2/5] Updated asciicast url Signed-off-by: Dimitris Zlatanidis --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cb0c21e..caa40f30 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ display warning messages, etc. #### Asciicast: -[](https://asciinema.org/a/3uFNAOX8o16AmKKJDIvdezPBa) +[](https://asciinema.org/a/3uFNAOX8o16AmKKJDIvdezPBa) ##### Copyright From e583ffdbc6a5111007523a2b09073b573a323f4d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 10 Dec 2019 23:22:58 +0100 Subject: [PATCH 3/5] Bugfix: Slackware-current from Alien Bob 20191130 #119 Signed-off-by: Dimitris Zlatanidis --- slpkg/file_size.py | 8 ++++---- slpkg/init.py | 22 ++++++++++++---------- slpkg/url_read.py | 10 +++++----- slpkg/utils.py | 10 ++++++++++ 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/slpkg/file_size.py b/slpkg/file_size.py index 3dd901a6..2b178776 100644 --- a/slpkg/file_size.py +++ b/slpkg/file_size.py @@ -23,7 +23,7 @@ import os -import requests +import urllib3 class FileSize: @@ -31,15 +31,15 @@ class FileSize: """ def __init__(self, registry): self.registry = registry + self.http = urllib3.PoolManager() def server(self): """Returns the size of remote files """ try: - r = requests.head(self.registry) + r = self.http.request("GET", self.registry) return int(r.headers["Content-Length"]) - except (requests.exceptions.Timeout, - requests.exceptions.ConnectionError): + except urllib3.exceptions.NewConnectionError: return " " def local(self): diff --git a/slpkg/init.py b/slpkg/init.py index 209c3ed6..5d072d68 100644 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -25,6 +25,7 @@ import os import shutil +from slpkg.utils import Utils from slpkg.repositories import Repo from slpkg.file_size import FileSize from slpkg.downloader import Download @@ -701,10 +702,13 @@ class Initialization: def merge(self, path, outfile, infiles): """Merge files """ - with open(path + outfile, 'w') as out_f: - for i in infiles: - if os.path.isfile("{0}{1}".format(path, i)): - with open(path + i, "r") as in_f: + code = "utf-8" + with open(path + outfile, 'w', encoding=code) as out_f: + for f in infiles: + if os.path.isfile("{0}{1}".format(path, f)): + # checking the encoding before read the file + code = Utils.check_encoding(path, f) + with open(path + f, "r", encoding=code) as in_f: for line in in_f: out_f.write(line) @@ -770,12 +774,10 @@ class Update(object): if check_for_local_repos(repo) is True: continue print("{0}Check repository [{1}{2}{3}] ... " - "{4}".format( - self.meta.color["GREY"], - self.meta.color["CYAN"], repo, - self.meta.color["GREY"], - self.meta.color["ENDC"]), end="") - print(end="", flush=True) + "{4}".format(self.meta.color["GREY"], + self.meta.color["CYAN"], repo, + self.meta.color["GREY"], + self.meta.color["ENDC"]), end="", flush=True) if repo in default: exec("{0}.{1}()".format(self._init, repo)) print(self.done, end="") diff --git a/slpkg/url_read.py b/slpkg/url_read.py index 4cb17e57..ba26139a 100644 --- a/slpkg/url_read.py +++ b/slpkg/url_read.py @@ -22,7 +22,7 @@ # along with this program. If not, see . -import requests +import urllib3 from slpkg.__metadata__ import MetaData as _meta_ @@ -33,15 +33,15 @@ class URL: def __init__(self, link): self.link = link self.meta = _meta_ + self.http = urllib3.PoolManager() def reading(self): """Open url and read """ try: - f = requests.get(self.link) - return f.text - except (requests.exceptions.Timeout, - requests.exceptions.ConnectionError): + f = self.http.request('GET', self.link) + return f.data.decode("utf-8") + except urllib3.exceptions.NewConnectionError: print("\n{0}Can't read the file '{1}'{2}".format( self.meta.color["RED"], self.link.split("/")[-1], self.meta.color["ENDC"])) diff --git a/slpkg/utils.py b/slpkg/utils.py index d3a39357..fd9b28af 100644 --- a/slpkg/utils.py +++ b/slpkg/utils.py @@ -102,6 +102,16 @@ class Utils: else: return file_name + @staticmethod + def check_encoding(path, f): + """Checking the file encoding default is utf-8 + """ + try: + with open(path + f, "r") as ftest: + ftest.read() + except UnicodeDecodeError: + return "ISO-8859-1" + def debug(self, test): """Function used for print some stuff for debugging """ From d3fa8949b1fc3c3b75dcb1f607e183a2204d409b Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 11 Dec 2019 13:49:45 +0100 Subject: [PATCH 4/5] Improving call class methods for updating Signed-off-by: Dimitris Zlatanidis --- slpkg/init.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/slpkg/init.py b/slpkg/init.py index 5d072d68..9ae00f93 100644 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -752,10 +752,10 @@ class Initialization: Update().repository(only) -class Update(object): +class Update: def __init__(self): - self._init = "Initialization(False)" + self.initialization = globals()['Initialization'](False) self.meta = _meta_ self.done = "{0}Done{1}\n".format(self.meta.color["GREY"], self.meta.color["ENDC"]) @@ -779,7 +779,8 @@ class Update(object): self.meta.color["GREY"], self.meta.color["ENDC"]), end="", flush=True) if repo in default: - exec("{0}.{1}()".format(self._init, repo)) + update = getattr(self.initialization, repo) + update() print(self.done, end="") elif repo in enabled: Initialization(False).custom(repo) From c1f1833eebb8da4fb25ce2ee41af6a3cf60a0e6f Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 11 Dec 2019 15:19:54 +0100 Subject: [PATCH 5/5] Updated for version 3.7.3 Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 9 ++++++--- README.md | 2 +- requirements.txt | 2 +- setup.py | 2 +- slpkg/__metadata__.py | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 6e5d55a0..faedc89c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,9 @@ -3.7.3 - 06/12/2019 -Fixed: -- code style to python3 compatibility +3.7.3 - 11/12/2019 +FIxed: +- Bugfix: Slackware-current from Alien Bob 20191130 #119 +- Improving call class methods for reposiory updating +- Replace requests dependency with urllib3 +- Code style to python3 compatibility 3.7.2 - 06/12/2019 Fixed: diff --git a/README.md b/README.md index caa40f30..22382b34 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# slpkg 3.7.2 +# slpkg 3.7.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/requirements.txt b/requirements.txt index 2edcd05f..8eeb20f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,4 @@ # perl 5 language and graph-easy >= 0.75 (drawing dependencies ascii diagram) # python3-pythondialog >= 3.5.0 (Python interface to the UNIX dialog utility) -python-requests >= 2.22.0 +urllib3 >= 1.25.7 diff --git a/setup.py b/setup.py index 25e90606..4896a5ad 100755 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ except ImportError: docs_requires = [] tests_requires = [] install_requires = [ - "requests>=2.22.0" + "urllib3>=1.25.7" ] optional_requires = [ "pythondialog>=3.5.0", diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index bda10ff3..0f7f19d6 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -78,7 +78,7 @@ class MetaData: __all__ = "slpkg" __author__ = "dslackw" - __version_info__ = (3, 7, 2) + __version_info__ = (3, 7, 3) __version__ = "{0}.{1}.{2}".format(*__version_info__) __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com"