From bf0fd34b6f515523e5f41ad909fd7734d0187beb Mon Sep 17 00:00:00 2001 From: Howard Johnson Date: Jan 19 2017 11:24:22 +0000 Subject: More upload PyCURL fixes for EL 7 A couple more values need converting from unicode to str in remote_file_exists() and upload(). Signed-off-by: Howard Johnson --- diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3b0031c..631e658 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ ChangeLog ========= +Next +---- + +- More upload PyCURL fixes for EL 7 (merlinthp) + v1.48 (2016-12-22) ------------------ @@ -14,7 +19,7 @@ v1.47 (2016-12-15) - Fix upload with old PyCURL - BZ#1241059 (lsedlar) - Default krb_rdns to None (lsedlar) - Add missing krb_rdns in default Koji config (cqi) -- Coerce the distgit_namespaced config option to a boolean - #74 (merlin) +- Coerce the distgit_namespaced config option to a boolean - #74 (merlinthp) - We need krb_rdns (puiterwijk) - Fix wrong _has_krb_creds name (cqi) - Warning if repo is an old checkout - #148 (cqi) diff --git a/pyrpkg/lookaside.py b/pyrpkg/lookaside.py index 18823b7..4c48411 100644 --- a/pyrpkg/lookaside.py +++ b/pyrpkg/lookaside.py @@ -206,6 +206,14 @@ class CGILookasideCache(object): filename: The name of the file to check for. hash: The known good hash of the file. """ + + # RHEL 7 ships pycurl that does not accept unicode. When given unicode + # type it would explode with "unsupported second type in tuple". Let's + # convert to str just to be sure. + # https://bugzilla.redhat.com/show_bug.cgi?id=1241059 + if six.PY2 and isinstance(filename, unicode): + filename = filename.encode('utf-8') + post_data = [('name', name), ('%ssum' % self.hashtype, hash), ('filename', filename)] @@ -270,12 +278,12 @@ class CGILookasideCache(object): """ filename = os.path.basename(filepath) - # RHEL 7 ships pycurl that does not accept unicode. When given unicode - # type it would explode with "unsupported second type in tuple". Let's - # convert to str just to be sure. - # https://bugzilla.redhat.com/show_bug.cgi?id=1241059 - if six.PY2 and isinstance(name, unicode): - name = name.encode('utf-8') + # As in remote_file_exists, we need to convert unicode strings to str + if six.PY2: + if isinstance(name, unicode): + name = name.encode('utf-8') + if isinstance(filepath, unicode): + filepath = filepath.encode('utf-8') if self.remote_file_exists(name, filename, hash): self.log.info("File already uploaded: %s", filepath)