diff --git a/ChangeLog.txt b/ChangeLog.txt index e78b56c3..a359fcdd 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +3.7.0 - 1/12/2019 +Updated: +- Switch to python3 + 3.4.3 - 19/05/2019 Updated: - Update gen_repos_files.sh to version 1.94 diff --git a/INSTALL.md b/INSTALL.md index fa31fbee..2de1a12d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -3,7 +3,7 @@ ##### Python & OS Support -Slpkg works with Python versions 2.7.5+ . +Slpkg works with Python versions 3.7+ . Slpkg works on Slackware distribution and possibly in some Slackware based distribution like SalixOS, Slackel etc. @@ -22,4 +22,4 @@ 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.4.3/slpkg-3.4.3.tar.gz`' +3. Using pip: '`pip install https://gitlab.com/dslackw/slpkg/-/archive/3.7.0/slpkg-3.7.0.tar.gz`' diff --git a/KNOWN_ISSUES b/KNOWN_ISSUES index 1a0cf150..68789eb2 100644 --- a/KNOWN_ISSUES +++ b/KNOWN_ISSUES @@ -1,9 +1 @@ Known issues: - -- Dialog utility crash in option --buildlist when move with arrows - sometimes without yet that create big issues. - Issues reference here: - https://sourceforge.net/p/pythondialog/bugs/6/ - - Upgrade dialog utility from here if only necessary: - https://gitlab.com/dslackw/SlackBuilds/tree/master/dialog diff --git a/bin/slpkg b/bin/slpkg index 573fb380..86e5f175 100755 --- a/bin/slpkg +++ b/bin/slpkg @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # slpkg file is part of slpkg. diff --git a/clean.py b/clean.py index 39d63a07..4977f651 100755 --- a/clean.py +++ b/clean.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # clean.py file is part of slpkg. diff --git a/man/slpkg.8 b/man/slpkg.8 index 56723275..42db813e 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -68,7 +68,7 @@ Remove custom repository by name. .SS repo-enable, enable or disable repositories \fBslpkg\fP \fBrepo-enable\fP .PP -Enable or disable repositories via dialog utility (require python2-pythondialog) +Enable or disable repositories via dialog utility (require python3-pythondialog) .SS repo-list, repositories list \fBslpkg\fP \fBrepo-list\fP @@ -268,7 +268,7 @@ build or install etc. Use "--checklist" additional option to load all repository .PP Additional options: .PP -\fB--checklist\fP : Enable dialog utility and checklist option. (Require python2-pythondialog) +\fB--checklist\fP : Enable dialog utility and checklist option. (Require python3-pythondialog) .PP \fB--case-ins\fP : Search package name in repository with case insensitive. @@ -304,7 +304,7 @@ Additional options: .PP \fB--tag\fP : Remove packages with by TAG. .PP -\fB--checklist\fP : Enable dialog utility and checklist option. (Require python2-pythondialog) +\fB--checklist\fP : Enable dialog utility and checklist option. (Require python3-pythondialog) .PP \fB--third-party\fP : Remove all the third-party packages. (Be sure update the package lists before) diff --git a/requirements.txt b/requirements.txt index e4ea7f59..d6717b83 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # Slackware Linux (based) -# Python 2.7+ +# Python 3.7+ # GNU wget # GNU coreutils # @@ -9,4 +9,4 @@ # httpie (alternative downloader) # pygraphviz >= 1.3.1 (drawing dependencies diagram) # perl 5 language and graph-easy >= 0.75 (drawing dependencies ascii diagram) -# python2-pythondialog >= 3.3.0 (Python interface to the UNIX dialog utility) +# python3-pythondialog >= 3.3.0 (Python interface to the UNIX dialog utility) diff --git a/setup.py b/setup.py index 5487a921..8b3d55f1 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # setup.py file is part of slpkg. @@ -38,7 +38,7 @@ INSTALLATION_REQUIREMENTS = [] DOCS_REQUIREMENTS = [] TESTS_REQUIREMENTS = [] OPTIONAL_REQUIREMENTS = [ - "python2-pythondialog >= 3.3.0", + "python3-pythondialog >= 3.3.0", "pygraphviz >= 1.3.1" ] @@ -86,9 +86,7 @@ setup( "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: POSIX :: Linux", "Operating System :: Unix", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", "Programming Language :: Unix Shell", "Topic :: Software Development :: Build Tools", "Topic :: System :: Archiving :: Packaging", diff --git a/slackbuild/README b/slackbuild/README index 80c0f115..ef10d2b7 100644 --- a/slackbuild/README +++ b/slackbuild/README @@ -5,7 +5,7 @@ to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. Optional dependencies: - python2-pythondialog (for dialog box interface) + python3-pythondialog (for dialog box interface) pygraphviz (for drawing dependencies diagram) graph-easy (for drawing ascii dependencies diagram) aria2 (alternative downloader) diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index 2d5b3735..437131cd 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -63,9 +63,6 @@ fi set -e -PYTHON=python -# [ "${PYTHON3:-no}" = "yes" ] && PYTHON=python3 - rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP @@ -83,14 +80,7 @@ find -L . \ # skip pip installs sed -i 's/if "install"/if ""/' setup.py -# Python 3 support temporarily is out until new Slackware version -# will be release -# if [ "$PYTHON3" = "yes" ]; then -# sh convert-py3k -# cd py3k/$PRGNAM -#fi - -$PYTHON setup.py install --root=$PKG +python3 setup.py install --root=$PKG find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index 4acc08d0..5e3c35e5 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # __metadata__.py file is part of slpkg. @@ -78,7 +78,7 @@ class MetaData(object): __all__ = "slpkg" __author__ = "dslackw" - __version_info__ = (3, 4, 3) + __version_info__ = (3, 7, 0) __version__ = "{0}.{1}.{2}".format(*__version_info__) __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com" diff --git a/slpkg/arguments.py b/slpkg/arguments.py index a61ebaf1..c88907bf 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # arguments.py file is part of slpkg. diff --git a/slpkg/auto_pkg.py b/slpkg/auto_pkg.py index a82c20ec..93520747 100644 --- a/slpkg/auto_pkg.py +++ b/slpkg/auto_pkg.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # auto_pkg.py file is part of slpkg. @@ -60,15 +60,15 @@ class Auto(object): self.meta.color["ENDC"])) self.msg.template(78) try: - self.choice = raw_input(" > ") + self.choice = input(" > ") except EOFError: print("") raise SystemExit() if self.choice in self.commands.keys(): - sys.stdout.write(" \x1b[1A{0}{1}{2}\n\n".format( + print(" \x1b[1A{0}{1}{2}\n\n".format( self.meta.color["CYAN"], self.commands[self.choice], - self.meta.color["ENDC"])) - sys.stdout.flush() + self.meta.color["ENDC"]), end="") + print(end="", flush=True) self.execute() def execute(self): diff --git a/slpkg/binary/check.py b/slpkg/binary/check.py index cd6c6910..d6c14459 100644 --- a/slpkg/binary/check.py +++ b/slpkg/binary/check.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # check.py file is part of slpkg. @@ -22,7 +22,7 @@ # along with this program. If not, see . -from distutils.version import LooseVersion +from pkg_resources import parse_version from slpkg.messages import Msg from slpkg.toolbar import status @@ -54,7 +54,7 @@ def pkg_upgrade(repo, skip, flag): if name: # this tips because some pkg_name is empty repo_pkg = split_package(name[:-4]) if (repo_pkg[0] == inst_pkg[0] and - LooseVersion(repo_pkg[1]) > LooseVersion(inst_pkg[1]) and + parse_version(repo_pkg[1]) > parse_version(inst_pkg[1]) and repo_pkg[3] >= inst_pkg[3] and inst_pkg[0] not in skip and repo_pkg[1] != "blacklist"): diff --git a/slpkg/binary/dependency.py b/slpkg/binary/dependency.py index cecab35e..9461dc9f 100644 --- a/slpkg/binary/dependency.py +++ b/slpkg/binary/dependency.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # dependency.py file is part of slpkg. diff --git a/slpkg/binary/greps.py b/slpkg/binary/greps.py index 9aa52167..38988cc1 100644 --- a/slpkg/binary/greps.py +++ b/slpkg/binary/greps.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # greps.py file is part of slpkg. diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 2a760e88..4db3605d 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # install.py file is part of slpkg. @@ -23,7 +23,7 @@ import os -from distutils.version import LooseVersion +from pkg_resources import parse_version from slpkg.utils import Utils from slpkg.sizes import units @@ -192,7 +192,7 @@ class BinaryInstall(object): data_dict = Utils().case_sensitive(data) for pkg in self.packages: index = self.packages.index(pkg) - for key, value in data_dict.iteritems(): + for key, value in data_dict.items(): if key == pkg.lower(): self.packages[index] = value @@ -247,7 +247,7 @@ class BinaryInstall(object): ins_ver = GetFromInstalled(name).version()[1:] if not ins_ver: ins_ver = "0" - if LooseVersion(rep_ver) < LooseVersion(ins_ver): + if parse_version(rep_ver) < parse_version(ins_ver): self.msg.template(78) print("| Package {0} don't downgrade, " "setting by user".format(name)) @@ -308,7 +308,7 @@ class BinaryInstall(object): " " * (18-len(pkg_repo[1])), pkg_repo[2], " " * (8-len(pkg_repo[2])), pkg_repo[3], " " * (7-len(pkg_repo[3])), repo, - comp, " K")).rstrip() + comp, " K").rstrip()) return [pkg_sum, upg_sum, uni_sum] def top_view(self): diff --git a/slpkg/binary/repo_init.py b/slpkg/binary/repo_init.py index 53e29854..a6d47e5a 100644 --- a/slpkg/binary/repo_init.py +++ b/slpkg/binary/repo_init.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # repo_init.py file is part of slpkg. diff --git a/slpkg/binary/search.py b/slpkg/binary/search.py index fc50b673..a5526bc1 100644 --- a/slpkg/binary/search.py +++ b/slpkg/binary/search.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # search.py file is part of slpkg. diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index d87b5916..1675985a 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # blacklist.py file is part of slpkg. diff --git a/slpkg/checks.py b/slpkg/checks.py index 887763e6..60b187f2 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # checks.py file is part of slpkg. diff --git a/slpkg/checksum.py b/slpkg/checksum.py index a35daa75..685a91c0 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # checksum.py file is part of slpkg. diff --git a/slpkg/clean.py b/slpkg/clean.py index 894a0a10..4bea6610 100644 --- a/slpkg/clean.py +++ b/slpkg/clean.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # clean.py file is part of slpkg. diff --git a/slpkg/config.py b/slpkg/config.py index 37f08a45..744f1b4c 100644 --- a/slpkg/config.py +++ b/slpkg/config.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # config.py file is part of slpkg. diff --git a/slpkg/desc.py b/slpkg/desc.py index c1e9c9a1..73f78946 100644 --- a/slpkg/desc.py +++ b/slpkg/desc.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # desc.py file is part of slpkg. diff --git a/slpkg/dialog_box.py b/slpkg/dialog_box.py index 4fe32a7a..1932e98b 100644 --- a/slpkg/dialog_box.py +++ b/slpkg/dialog_box.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # dialog_box.py file is part of slpkg. diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 4c41dea8..d15d0079 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # downloader.py file is part of slpkg. diff --git a/slpkg/file_size.py b/slpkg/file_size.py index 3d63c155..f5b80859 100644 --- a/slpkg/file_size.py +++ b/slpkg/file_size.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -* # file_size.py file is part of slpkg. @@ -23,7 +23,8 @@ import os -import urllib2 +import urllib +from urllib.request import urlopen class FileSize(object): @@ -36,10 +37,10 @@ class FileSize(object): """Returns the size of remote files """ try: - tar = urllib2.urlopen(self.registry) + tar = urlopen(self.registry) meta = tar.info() - return int(meta.getheaders("Content-Length")[0]) - except (urllib2.URLError, IndexError): + return int(meta.get_all("Content-Length")[0]) + except (urllib.error.URLError, IndexError): return " " def local(self): diff --git a/slpkg/graph.py b/slpkg/graph.py index 5d115413..d874c4ac 100644 --- a/slpkg/graph.py +++ b/slpkg/graph.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # graph.py file is part of slpkg. diff --git a/slpkg/grep_md5.py b/slpkg/grep_md5.py index 552e2194..6168dd8b 100644 --- a/slpkg/grep_md5.py +++ b/slpkg/grep_md5.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # grep_md5.py file is part of slpkg. diff --git a/slpkg/health.py b/slpkg/health.py index 9fa844c6..011cb84e 100644 --- a/slpkg/health.py +++ b/slpkg/health.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # health.py file is part of slpkg. diff --git a/slpkg/init.py b/slpkg/init.py index c0a37fea..20ce4320 100644 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # init.py file is part of slpkg. @@ -23,7 +23,6 @@ import os -import sys import shutil from slpkg.repositories import Repo @@ -770,21 +769,21 @@ class Update(object): for repo in enabled: if check_for_local_repos(repo) is True: continue - sys.stdout.write("{0}Check repository [{1}{2}{3}] ... " + 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"])) - sys.stdout.flush() + self.meta.color["ENDC"]), end="") + print(end="", flush=True) if repo in default: exec("{0}.{1}()".format(self._init, repo)) - sys.stdout.write(self.done) + print(self.done, end="") elif repo in enabled: Initialization(False).custom(repo) - sys.stdout.write(self.done) + print(self.done, end="") else: - sys.stdout.write(self.error) + print(self.error, end="") print("") # new line at end raise SystemExit() diff --git a/slpkg/load.py b/slpkg/load.py index 65f86bb3..119dc21c 100644 --- a/slpkg/load.py +++ b/slpkg/load.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # load.py file is part of slpkg. diff --git a/slpkg/log_deps.py b/slpkg/log_deps.py index 5ba7cc80..7ddac2c1 100644 --- a/slpkg/log_deps.py +++ b/slpkg/log_deps.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # log_deps.py file is part of slpkg. @@ -33,7 +33,7 @@ def write_deps(deps_dict): """Write dependencies in a log file into directory `/var/log/slpkg/dep/` """ - for name, dependencies in deps_dict.iteritems(): + for name, dependencies in deps_dict.items(): if find_package(name + _meta_.sp, _meta_.pkg_path): dep_path = _meta_.log_path + "dep/" if not os.path.exists(dep_path): diff --git a/slpkg/main.py b/slpkg/main.py index af65d78b..464e37a6 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # main.py file is part of slpkg. diff --git a/slpkg/md5sum.py b/slpkg/md5sum.py index 716cb3f9..3d2c71ab 100644 --- a/slpkg/md5sum.py +++ b/slpkg/md5sum.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # md5sum.py file is part of slpkg. @@ -30,6 +30,6 @@ def md5(source): """ # fix passing char '+' from source source = source.replace("%2B", "+") - with open(source) as file_to_check: + with open(source, "rb") as file_to_check: data = file_to_check.read() return hashlib.md5(data).hexdigest() diff --git a/slpkg/messages.py b/slpkg/messages.py index e3fcc937..ac59f1e9 100644 --- a/slpkg/messages.py +++ b/slpkg/messages.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # messages.py file is part of slpkg. @@ -22,7 +22,6 @@ # along with this program. If not, see . -import sys import itertools from slpkg.__metadata__ import MetaData as _meta_ @@ -70,29 +69,29 @@ class Msg(object): def checking(self): """Message checking """ - sys.stdout.write("{0}Checking...{1} ".format(self.meta.color["GREY"], - self.meta.color["ENDC"])) - sys.stdout.flush() + print("{0}Checking...{1} ".format(self.meta.color["GREY"], + self.meta.color["ENDC"]), end="") + print(end="", flush=True) def reading(self): """Message reading """ - sys.stdout.write("{0}Reading package lists...{1} ".format( - self.meta.color["GREY"], self.meta.color["ENDC"])) - sys.stdout.flush() + print("{0}Reading package lists...{1} ".format( + self.meta.color["GREY"], self.meta.color["ENDC"]), end="") + print(end="", flush=True) def resolving(self): """Message resolving """ - sys.stdout.write("{0}Resolving dependencies...{1} ".format( - self.meta.color["GREY"], self.meta.color["ENDC"])) - sys.stdout.flush() + print("{0}Resolving dependencies...{1} ".format( + self.meta.color["GREY"], self.meta.color["ENDC"]), end="") + print(end="", flush=True) def done(self): """Message done """ - sys.stdout.write("\b{0}Done{1}\n".format(self.meta.color["GREY"], - self.meta.color["ENDC"])) + print("\b{0}Done{1}\n".format(self.meta.color["GREY"], + self.meta.color["ENDC"]), end="") def pkg(self, count): """Print singular plural @@ -125,7 +124,7 @@ class Msg(object): answer = self.meta.default_answer else: try: - answer = raw_input("Would you like to continue [y/N]? ") + answer = input("Would you like to continue [y/N]? ") except EOFError: print("") raise SystemExit() @@ -154,7 +153,7 @@ class Msg(object): len(install), self.pkg(len(install)), len(upgrade), self.pkg(len(upgrade)))) self.template(78) - for installed, upgraded in itertools.izip_longest(install, upgrade): + for installed, upgraded in itertools.zip_longest(install, upgrade): if upgraded: print("| Package {0} upgraded successfully".format(upgraded)) if installed: diff --git a/slpkg/new_config.py b/slpkg/new_config.py index 0c552578..97382316 100644 --- a/slpkg/new_config.py +++ b/slpkg/new_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # new_config.py file is part of slpkg. @@ -88,7 +88,7 @@ class NewConfig(object): print("| {0}Q{1}{2}uit from menu".format(self.red, self.endc, self.br)) self.msg.template(78) try: - choose = raw_input("\nWhat would you like to do [K/O/R/P/Q]? ") + choose = input("\nWhat would you like to do [K/O/R/P/Q]? ") except EOFError: print("") raise SystemExit() @@ -141,7 +141,7 @@ class NewConfig(object): """Choose what do to file by file """ print("") - prompt_ask = raw_input("{0} [K/O/R/D/M/Q]? ".format(n)) + prompt_ask = input("{0} [K/O/R/D/M/Q]? ".format(n)) print("") if prompt_ask in ("K", "k"): self.keep() diff --git a/slpkg/pkg/build.py b/slpkg/pkg/build.py index 78847acf..018627ab 100644 --- a/slpkg/pkg/build.py +++ b/slpkg/pkg/build.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # build.py file is part of slpkg. @@ -75,7 +75,7 @@ class BuildPackage(object): try: tar = tarfile.open(self.script) except Exception as err: - print err + print(err) raise SystemExit() tar.extractall() tar.close() diff --git a/slpkg/pkg/find.py b/slpkg/pkg/find.py index 858b4b00..0bacbaa1 100644 --- a/slpkg/pkg/find.py +++ b/slpkg/pkg/find.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # find.py file is part of slpkg. diff --git a/slpkg/pkg/installed.py b/slpkg/pkg/installed.py index 861e3854..b924e721 100644 --- a/slpkg/pkg/installed.py +++ b/slpkg/pkg/installed.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -* # installed.py file is part of slpkg. diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py index 86456275..fc469c61 100644 --- a/slpkg/pkg/manager.py +++ b/slpkg/pkg/manager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # manager.py file is part of slpkg. @@ -108,7 +108,7 @@ class PackageManager(object): if self.meta.default_answer in ["y", "Y"]: remove_pkg = self.meta.default_answer else: - remove_pkg = raw_input( + remove_pkg = input( "\nAre you sure to remove {0} {1} [y/N]? ".format( str(len(self.removed)), msg)) except EOFError: @@ -144,7 +144,7 @@ class PackageManager(object): remove_dep = self.meta.remove_deps_answer else: try: - remove_dep = raw_input( + remove_dep = input( "\nRemove dependencies (maybe used by " "other packages) [y/N]? ") print("") @@ -223,8 +223,8 @@ class PackageManager(object): if "--third-party" in self.extra: print("\n") self.msg.template(78) - print("| {0}{1}*** WARNING ***{2}").format( - " " * 27, self.meta.color["RED"], self.meta.color["ENDC"]) + print(("| {0}{1}*** WARNING ***{2}").format( + " " * 27, self.meta.color["RED"], self.meta.color["ENDC"])) print("| Before you use third-party option, be sure you have" " updated the packages \n| lists. Run the command" " 'slpkg update' and 'slpkg -c slack --upgrade'") @@ -337,7 +337,7 @@ class PackageManager(object): print("| Insert packages to exception remove:") self.msg.template(78) try: - self.skip = raw_input(" > ").split() + self.skip = input(" > ").split() except EOFError: print("") raise SystemExit() @@ -519,7 +519,7 @@ class PackageManager(object): self.meta.color["GREY"], index, self.meta.color["ENDC"], pkg)) if index == page: - read = raw_input("\nPress {0}Enter{1} to " + read = input("\nPress {0}Enter{1} to " "continue... ".format( self.meta.color["CYAN"], self.meta.color["ENDC"])) diff --git a/slpkg/pkg_find.py b/slpkg/pkg_find.py index ee21f05f..af197e01 100644 --- a/slpkg/pkg_find.py +++ b/slpkg/pkg_find.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # pkg_find.py file is part of slpkg. diff --git a/slpkg/remove.py b/slpkg/remove.py index 906974a5..c8d8fea4 100644 --- a/slpkg/remove.py +++ b/slpkg/remove.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # remove.py file is part of slpkg. diff --git a/slpkg/repoenable.py b/slpkg/repoenable.py index 7be80758..6c5dde1d 100644 --- a/slpkg/repoenable.py +++ b/slpkg/repoenable.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # repoenable.py file is part of slpkg. diff --git a/slpkg/repoinfo.py b/slpkg/repoinfo.py index ba20ebf2..e98c4066 100644 --- a/slpkg/repoinfo.py +++ b/slpkg/repoinfo.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # repoinfo.py file is part of slpkg. @@ -99,8 +99,8 @@ class RepoInfo(object): self.form["Status:"] = status self.form["Last updated:"] = last_upd print("") - for key, value in sorted(self.form.iteritems()): - print self.meta.color["GREY"] + key + self.meta.color["ENDC"], value + for key, value in sorted(self.form.items()): + print(self.meta.color["GREY"] + key + self.meta.color["ENDC"], value) print("") raise SystemExit() diff --git a/slpkg/repolist.py b/slpkg/repolist.py index 3bb0c807..aa74dce8 100644 --- a/slpkg/repolist.py +++ b/slpkg/repolist.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # repolist.py file is part of slpkg. @@ -49,7 +49,7 @@ class RepoList(object): "Default", " " * 3, "Status")) self.msg.template(78) - for repo_id, repo_URL in sorted(self.all_repos.iteritems()): + for repo_id, repo_URL in sorted(self.all_repos.items()): status, COLOR = "disabled", self.meta.color["RED"] default = "yes" if len(repo_URL) > 49: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index ab58ab00..44170ed1 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # repositories.py file is part of slpkg. diff --git a/slpkg/sbo/autobuild.py b/slpkg/sbo/autobuild.py index 6e1c70ef..e5b04b18 100644 --- a/slpkg/sbo/autobuild.py +++ b/slpkg/sbo/autobuild.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # autobuild.py file is part of slpkg. diff --git a/slpkg/sbo/build_num.py b/slpkg/sbo/build_num.py index 9bd66a13..6eb75738 100644 --- a/slpkg/sbo/build_num.py +++ b/slpkg/sbo/build_num.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # build_num.py file is part of slpkg. diff --git a/slpkg/sbo/check.py b/slpkg/sbo/check.py index 5d6129fe..b0e39a9d 100644 --- a/slpkg/sbo/check.py +++ b/slpkg/sbo/check.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # check.py file is part of slpkg. @@ -23,7 +23,7 @@ import os -from distutils.version import LooseVersion +from pkg_resources import parse_version from slpkg.messages import Msg from slpkg.toolbar import status @@ -49,7 +49,7 @@ def sbo_upgrade(skip, flag): if (name in data and name not in skip and name not in blacklist): sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version())) package = ("{0}-{1}".format(name, ver)) - if LooseVersion(sbo_package) > LooseVersion(package): + if parse_version(sbo_package) > parse_version(package): upgrade_names.append(name) Msg().done() if "--checklist" in flag: diff --git a/slpkg/sbo/compressed.py b/slpkg/sbo/compressed.py index 98917d29..637c17d2 100644 --- a/slpkg/sbo/compressed.py +++ b/slpkg/sbo/compressed.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # download.py file is part of slpkg. diff --git a/slpkg/sbo/dependency.py b/slpkg/sbo/dependency.py index c12550d7..9535d314 100644 --- a/slpkg/sbo/dependency.py +++ b/slpkg/sbo/dependency.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # dependency.py file is part of slpkg. diff --git a/slpkg/sbo/greps.py b/slpkg/sbo/greps.py index 03ffae28..d987971c 100644 --- a/slpkg/sbo/greps.py +++ b/slpkg/sbo/greps.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # greps.py file is part of slpkg. diff --git a/slpkg/sbo/network.py b/slpkg/sbo/network.py index d2e6dffc..e9dcaec6 100644 --- a/slpkg/sbo/network.py +++ b/slpkg/sbo/network.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # network.py file is part of slpkg. @@ -137,7 +137,7 @@ class SBoNetwork(object): """ if "--case-ins" in self.flag: data_dict = Utils().case_sensitive(self.data) - for key, value in data_dict.iteritems(): + for key, value in data_dict.items(): if key == self.name.lower(): self.name = value @@ -171,16 +171,16 @@ class SBoNetwork(object): } try: message = " Choose an option > " - self.choice = raw_input("{0}{1}{2}".format(self.grey, message, + self.choice = input("{0}{1}{2}".format(self.grey, message, self.endc)) except EOFError: print("") raise SystemExit() try: - sys.stdout.write("{0}\x1b[1A{1}{2}{3}\n".format( + print("{0}\x1b[1A{1}{2}{3}\n".format( " " * len(message), self.cyan, commands[self.choice], - self.endc)) - sys.stdout.flush() + self.endc), end="") + print(end="", flush=True) except KeyError: pass diff --git a/slpkg/sbo/queue.py b/slpkg/sbo/queue.py index 7649ff88..eef9f5a5 100644 --- a/slpkg/sbo/queue.py +++ b/slpkg/sbo/queue.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # queue.py file is part of slpkg. diff --git a/slpkg/sbo/read.py b/slpkg/sbo/read.py index 61719003..72d55b5c 100644 --- a/slpkg/sbo/read.py +++ b/slpkg/sbo/read.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # read.py file is part of slpkg. diff --git a/slpkg/sbo/sbo_arch.py b/slpkg/sbo/sbo_arch.py index c20a1f3a..9e0f6b3a 100644 --- a/slpkg/sbo/sbo_arch.py +++ b/slpkg/sbo/sbo_arch.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # sbo_arch.py file is part of slpkg. diff --git a/slpkg/sbo/search.py b/slpkg/sbo/search.py index 0fed1e95..5eefe4a2 100644 --- a/slpkg/sbo/search.py +++ b/slpkg/sbo/search.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # search.py file is part of slpkg. diff --git a/slpkg/sbo/slack_find.py b/slpkg/sbo/slack_find.py index 4b242063..5001ab88 100644 --- a/slpkg/sbo/slack_find.py +++ b/slpkg/sbo/slack_find.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # slack_find.py file is part of slpkg. @@ -22,7 +22,7 @@ # along with this program. If not, see . -from distutils.version import LooseVersion +from pkg_resources import parse_version from slpkg.messages import Msg from slpkg.__metadata__ import MetaData as _meta_ @@ -38,7 +38,8 @@ def slack_package(prgnam): if pkg.startswith(prgnam) and pkg[:-4].endswith("_SBo"): binaries.append(pkg) for bins in binaries: - if LooseVersion(bins) > LooseVersion(cache): + binary = bins + if parse_version(bins) > parse_version(cache): binary = bins cache = binary if not binary: diff --git a/slpkg/sbo/slackbuild.py b/slpkg/sbo/slackbuild.py index 06143ae7..2a939340 100644 --- a/slpkg/sbo/slackbuild.py +++ b/slpkg/sbo/slackbuild.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # slackbuild.py file is part of slpkg. @@ -23,7 +23,7 @@ import os -from distutils.version import LooseVersion +from pkg_resources import parse_version from slpkg.utils import Utils @@ -171,7 +171,7 @@ class SBoInstall(object): data_dict = Utils().case_sensitive(self.data) for name in self.slackbuilds: index = self.slackbuilds.index(name) - for key, value in data_dict.iteritems(): + for key, value in data_dict.items(): if key == name.lower(): self.slackbuilds[index] = value @@ -272,7 +272,7 @@ class SBoInstall(object): " " * (23-len(args[1] + ver)), args[2], " " * (18-len(args[2])), args[3], " " * (15-len(args[3])), "", - "", "SBo", "", "")).rstrip() + "", "SBo", "", "").rstrip()) def tag(self, sbo): """Tag with color green if package already installed, @@ -382,7 +382,7 @@ class SBoInstall(object): ins_ver = GetFromInstalled(name).version()[1:] if not ins_ver: ins_ver = "0" - if LooseVersion(sbo_ver) < LooseVersion(ins_ver): + if parse_version(sbo_ver) < parse_version(ins_ver): self.msg.template(78) print("| Package {0} don't downgrade, " "setting by user".format(name)) diff --git a/slpkg/security.py b/slpkg/security.py index 6ceee5b5..e7bcbcd1 100644 --- a/slpkg/security.py +++ b/slpkg/security.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # security.py file is part of slpkg. diff --git a/slpkg/sizes.py b/slpkg/sizes.py index 98dd0cd0..ec55678a 100644 --- a/slpkg/sizes.py +++ b/slpkg/sizes.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # sizes.py file is part of slpkg. diff --git a/slpkg/slack/mirrors.py b/slpkg/slack/mirrors.py index 38956227..3de98493 100644 --- a/slpkg/slack/mirrors.py +++ b/slpkg/slack/mirrors.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # mirrors.py file is part of slpkg. diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index a446825e..f052ed7c 100644 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # patches.py file is part of slpkg. @@ -105,7 +105,7 @@ class Patches(object): print("{0}Total {1} {2} will be upgraded and {3} will be " "installed.".format(self.meta.color["GREY"], self.count_upg, - self.msg.pkg(self.upgrade_all), + self.msg.pkg(len(self.upgrade_all)), self.count_added)) print("Need to get {0} {1} of archives.".format(size[0], unit[0])) @@ -201,7 +201,7 @@ class Patches(object): " " * (18-len(pkg_repo[1])), pkg_repo[2], " " * (8-len(pkg_repo[2])), pkg_repo[3], " " * (7-len(pkg_repo[3])), "Slack", - size, " K")).rstrip() + size, " K").rstrip()) def upgrade(self): """ @@ -246,7 +246,7 @@ class Patches(object): print("| L=lilo / E=elilo / G=grub") self.msg.template(78) try: - answer = raw_input("\nThe kernel has been upgraded, " + answer = input("\nThe kernel has been upgraded, " "reinstall boot loader [L/E/G]? ") except EOFError: print("") diff --git a/slpkg/slack/slack_version.py b/slpkg/slack/slack_version.py index 26e456ea..02dc2904 100644 --- a/slpkg/slack/slack_version.py +++ b/slpkg/slack/slack_version.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # slack_version.py file is part of slpkg. diff --git a/slpkg/slack/slackware_repo.py b/slpkg/slack/slackware_repo.py index ae88b4fa..65a0b2ec 100644 --- a/slpkg/slack/slackware_repo.py +++ b/slpkg/slack/slackware_repo.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # slackware_repo.py file is part of slpkg. diff --git a/slpkg/slpkg_update.py b/slpkg/slpkg_update.py index a30775e9..fa2f9987 100644 --- a/slpkg/slpkg_update.py +++ b/slpkg/slpkg_update.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # slpkg_update.py file is part of slpkg. @@ -59,7 +59,7 @@ def it_self_update(): print("\nNew version '{0}-{1}' is available !\n".format( _meta_.__all__, __new_version__)) try: - answer = raw_input("Would you like to upgrade [y/N]? ") + answer = input("Would you like to upgrade [y/N]? ") except EOFError: print("") raise SystemExit() diff --git a/slpkg/splitting.py b/slpkg/splitting.py index 50e28e1f..56d8bfbb 100644 --- a/slpkg/splitting.py +++ b/slpkg/splitting.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # splitting.py file is part of slpkg. diff --git a/slpkg/status_deps.py b/slpkg/status_deps.py index bcc4cafc..a275f68f 100644 --- a/slpkg/status_deps.py +++ b/slpkg/status_deps.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # status_deps.py file is part of slpkg. @@ -89,7 +89,7 @@ class DependenciesStatus(object): self.msg.template(78) print("| {0}{1}{2}".format("Dependencies", " " * 20, "Packages")) self.msg.template(78) - for key, value in self.dmap.iteritems(): + for key, value in self.dmap.items(): print(" {0}{1}{2}{3}{4}".format( self.green, key, self.endc, " " * (32-len(key)), ", ".join(value))) @@ -105,14 +105,14 @@ class DependenciesStatus(object): "| -- Packages") self.msg.template(78) self.data() - for pkg, dep in self.dmap.iteritems(): + for pkg, dep in self.dmap.items(): print("+ {0}{1}{2}".format(self.green, pkg, self.endc)) print("|") for d in dep: print("+-- {0}".format(d)) print("|") - sys.stdout.write("\x1b[1A{0}\n".format(" ")) - sys.stdout.flush() + print("\x1b[1A{0}\n".format(" "), end="") + print(end="", flush=True) self.summary() if self.image: Graph(self.image).dependencies(self.dmap) diff --git a/slpkg/superuser.py b/slpkg/superuser.py index 801789ec..6b2027b2 100644 --- a/slpkg/superuser.py +++ b/slpkg/superuser.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # superuser.py file is part of slpkg. diff --git a/slpkg/toolbar.py b/slpkg/toolbar.py index 2b22b1ca..485030da 100644 --- a/slpkg/toolbar.py +++ b/slpkg/toolbar.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # toolbar.py file is part of slpkg. @@ -34,7 +34,7 @@ def status(sec): if _meta_.prg_bar in ["on", "ON"]: syms = ["|", "/", "-", "\\"] for sym in syms: - sys.stdout.write("\b{0}{1}{2}".format(_meta_.color["GREY"], sym, - _meta_.color["ENDC"])) - sys.stdout.flush() + print("\b{0}{1}{2}".format(_meta_.color["GREY"], sym, + _meta_.color["ENDC"]), end="") + print(end="", flush=True) time.sleep(float(sec)) diff --git a/slpkg/tracking.py b/slpkg/tracking.py index 01817108..fb090b84 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # tracking.py file is part of slpkg. @@ -148,7 +148,7 @@ class TrackingDeps(object): if "--case-ins" in self.flag: data = SBoGrep(name="").names() data_dict = Utils().case_sensitive(data) - for key, value in data_dict.iteritems(): + for key, value in data_dict.items(): if key == self.name.lower(): self.name = value @@ -158,7 +158,7 @@ class TrackingDeps(object): """ if "--case-ins" in self.flag: data_dict = Utils().case_sensitive(self.names) - for key, value in data_dict.iteritems(): + for key, value in data_dict.items(): if key == self.name.lower(): self.name = value diff --git a/slpkg/upgrade_checklist.py b/slpkg/upgrade_checklist.py index 46673beb..34af366f 100644 --- a/slpkg/upgrade_checklist.py +++ b/slpkg/upgrade_checklist.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # upgrade_checklist.py file is part of slpkg. diff --git a/slpkg/url_read.py b/slpkg/url_read.py index 3ca19875..8ce04e35 100644 --- a/slpkg/url_read.py +++ b/slpkg/url_read.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # url_read.py file is part of slpkg. @@ -22,8 +22,9 @@ # along with this program. If not, see . -import os -import urllib2 +# import os +import urllib +from urllib.request import urlopen from slpkg.__metadata__ import MetaData as _meta_ @@ -39,6 +40,7 @@ class URL(object): """Open url and read """ try: + ''' # testing proxy proxies = {} try: @@ -54,11 +56,11 @@ class URL(object): proxy = urllib2.ProxyHandler(proxies) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) - # end testing - f = urllib2.urlopen(self.link) - return f.read() - except (urllib2.URLError, ValueError): + ''' + f = urlopen(self.link) + return f.read().decode("utf-8") + except (urllib.error.URLError, ValueError): 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 e762bff2..e423fabc 100644 --- a/slpkg/utils.py +++ b/slpkg/utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # utils.py file is part of slpkg. diff --git a/slpkg/version.py b/slpkg/version.py index accd7dd0..8f4ee290 100644 --- a/slpkg/version.py +++ b/slpkg/version.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # version.py file is part of slpkg.