From 1bc9e3c2ce3974b83bbfad739fab5982a591ca74 Mon Sep 17 00:00:00 2001 From: Klaus Umbach Date: Mon, 26 Aug 2019 17:02:05 +0200 Subject: [PATCH 1/5] transformed with 2to3 --- clamavmirror/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clamavmirror/__init__.py b/clamavmirror/__init__.py index b485647..0b4d807 100755 --- a/clamavmirror/__init__.py +++ b/clamavmirror/__init__.py @@ -69,7 +69,7 @@ import hashlib from shutil import move -from Queue import Queue +from queue import Queue from threading import Thread from optparse import OptionParser from subprocess import PIPE, Popen @@ -83,7 +83,7 @@ VERSION_INFO = (0, 0, 4) __author__ = "Andrew Colin Kissa" -__copyright__ = u"© 2016-2019 Andrew Colin Kissa" +__copyright__ = "© 2016-2019 Andrew Colin Kissa" __email__ = "andrew@topdog.za.net" __version__ = ".".join(map(str, VERSION_INFO)) @@ -118,18 +118,18 @@ def get_md5(string): def error(msg): """print to stderr""" - print >> sys.stderr, msg + print(msg, file=sys.stderr) def info(msg): """print to stdout""" - print >> sys.stdout, msg + print(msg, file=sys.stdout) def deploy_signature(source, dest, user=None, group=None): """Deploy a signature fole""" move(source, dest) - os.chmod(dest, 0644) + os.chmod(dest, 0o644) if user and group: try: uid = pwd.getpwnam(user).pw_uid From bd697a88e7662180646083a6febb571a84440f4c Mon Sep 17 00:00:00 2001 From: Klaus Umbach Date: Mon, 26 Aug 2019 17:28:56 +0200 Subject: [PATCH 2/5] fixes "python setup.py install" I got "ImportError: No module named clamavmirror" before. --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1ba23aa..b26374c 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ def main(): author_email="andrew@topdog.za.net", url="https://github.com/akissa/clamavmirror", license="MPL 2.0", - packages=[], + packages=['clamavmirror'], entry_points={ 'console_scripts': [ 'clamavmirror=clamavmirror:main' @@ -63,6 +63,7 @@ def main(): 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.7', 'Topic :: Software Development :: Libraries :: Python Modules', 'Intended Audience :: System Administrators', 'Environment :: Console', From fdaf846c1cf07745fc32ebf8dd68ab3689a5da51 Mon Sep 17 00:00:00 2001 From: Klaus Umbach Date: Mon, 26 Aug 2019 17:49:08 +0200 Subject: [PATCH 3/5] restored python2 compatibility --- clamavmirror/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clamavmirror/__init__.py b/clamavmirror/__init__.py index 0b4d807..dd554f4 100755 --- a/clamavmirror/__init__.py +++ b/clamavmirror/__init__.py @@ -60,6 +60,7 @@ -u andrew -g staff -a db.za.clamav.net \ -l ~/Downloads/ """ +from __future__ import print_function import os import pwd import grp @@ -69,7 +70,13 @@ import hashlib from shutil import move -from queue import Queue + +# queue is called Queue in python3 +if sys.version_info.major < 3: + from Queue import Queue +else: + from queue import Queue + from threading import Thread from optparse import OptionParser from subprocess import PIPE, Popen From 743897a206426fc5092033bfbc15d780d7e6d440 Mon Sep 17 00:00:00 2001 From: Klaus Umbach Date: Mon, 26 Aug 2019 19:23:00 +0200 Subject: [PATCH 4/5] fixes string/byte-handling for python3 --- clamavmirror/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clamavmirror/__init__.py b/clamavmirror/__init__.py index dd554f4..67f924e 100755 --- a/clamavmirror/__init__.py +++ b/clamavmirror/__init__.py @@ -119,7 +119,7 @@ def get_md5(string): hasher = hashlib.md5() except BaseException: hasher = hashlib.new('md5', usedForSecurity=False) - hasher.update(string) + hasher.update(string.encode('utf-8')) return hasher.hexdigest() @@ -156,7 +156,7 @@ def get_txt_record(hostname): """Get the text record""" try: answers = query(hostname, 'TXT') - return answers[0].strings[0] + return answers[0].strings[0].decode() except (IndexError, NXDOMAIN): return '' @@ -169,7 +169,7 @@ def get_local_version(sigdir, sig): cmd = ['sigtool', '-i', filename] sigtool = Popen(cmd, stdout=PIPE, stderr=PIPE) while True: - line = sigtool.stdout.readline() + line = sigtool.stdout.readline().decode() if line and line.startswith('Version:'): version = line.split()[1] break @@ -225,7 +225,7 @@ def download_sig(opts, sig, version=None): data = req.data code = req.status if req.status == 200: - with open(filename, 'w') as handle: + with open(filename, 'wb') as handle: handle.write(data) downloaded = os.path.exists(filename) return downloaded, code From 06237401da114c0317918041afd7e1c477dd1333 Mon Sep 17 00:00:00 2001 From: Klaus Umbach Date: Mon, 26 Aug 2019 19:39:34 +0200 Subject: [PATCH 5/5] fixed comment --- clamavmirror/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clamavmirror/__init__.py b/clamavmirror/__init__.py index 67f924e..0b26187 100755 --- a/clamavmirror/__init__.py +++ b/clamavmirror/__init__.py @@ -71,7 +71,7 @@ from shutil import move -# queue is called Queue in python3 +# Queue is called queue in python3 if sys.version_info.major < 3: from Queue import Queue else: