From ad3924e5b86d26763c52483c5470a072de381984 Mon Sep 17 00:00:00 2001 From: Vincent A Date: Mon, 25 Feb 2019 21:44:42 +0100 Subject: [PATCH] weboob-repos: port to python3 tarfile.add doesn't take anymore 'exclude' keyword anymore but 'filter' can do the same in both py2 and py3. Also, subprocess returns bytes. --- weboob/applications/weboobrepos/weboobrepos.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/weboob/applications/weboobrepos/weboobrepos.py b/weboob/applications/weboobrepos/weboobrepos.py index afe2625b95..06248ac8e4 100644 --- a/weboob/applications/weboobrepos/weboobrepos.py +++ b/weboob/applications/weboobrepos/weboobrepos.py @@ -149,7 +149,7 @@ def do_build(self, line): print('Create archive for %s' % name) with closing(tarfile.open(tarname, 'w:gz')) as tar: - tar.add(module_path, arcname=name, exclude=self._archive_excludes) + tar.add(module_path, arcname=name, filter=self._archive_excludes) tar_mtime = mktime(strptime(str(module.version), '%Y%m%d%H%M')) os.utime(tarname, (tar_mtime, tar_mtime)) @@ -164,7 +164,7 @@ def do_build(self, line): raise Exception('Unable to find the gpg executable.') # Find out which keys are allowed to sign - fingerprints = [gpgline.strip(':').split(':')[-1] + fingerprints = [gpgline.decode('utf-8').strip(':').split(':')[-1] for gpgline in subprocess.Popen([ gpg, @@ -174,7 +174,7 @@ def do_build(self, line): '--no-default-keyring', '--keyring', os.path.realpath(krname)], stdout=subprocess.PIPE).communicate()[0].splitlines() - if gpgline.startswith('fpr:')] + if gpgline.startswith(b'fpr:')] # Find out the first secret key we have that is allowed to sign secret_fingerprint = None for fingerprint in fingerprints: @@ -214,11 +214,12 @@ def do_build(self, line): os.utime(sigpath, (file_mtime, file_mtime)) print('Signatures are up to date') - def _archive_excludes(self, filename): + def _archive_excludes(self, tarinfo): + filename = tarinfo.name # Skip *.pyc files in tarballs. if filename.endswith('.pyc'): - return True + return # Don't include *.png files in tarball if filename.endswith('.png'): - return True - return False + return + return tarinfo -- GitLab