summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2019-05-12 08:54:01 +0200
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>2019-05-12 06:53:46 -0400
commit00fe99d7142c555aa76015d98835cef1e8018ef7 (patch)
tree59f672c675cc2c93098cc6e9cc42111d4a49baa6
parent0aa173653377de5dbb4c3960cd841c9855ae040e (diff)
downloadurlgrabber-00fe99d7142c555aa76015d98835cef1e8018ef7.tar.gz
urlgrabber-ext-down: another python 3 compat
Expect that _readlines() returns array of bytes objects in Python 3 environments. Fixes rhbz #1707657 and #1688173
-rwxr-xr-xscripts/urlgrabber-ext-down9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/urlgrabber-ext-down b/scripts/urlgrabber-ext-down
index bbaebd5..13d6dc7 100755
--- a/scripts/urlgrabber-ext-down
+++ b/scripts/urlgrabber-ext-down
@@ -19,12 +19,17 @@
# Boston, MA 02111-1307 USA
import time, os, errno, sys
+import six
from urlgrabber.grabber import \
_readlines, URLGrabberOptions, _loads, \
PyCurlFileObject, URLGrabError
def write(fmt, *arg):
- try: os.write(1, fmt % arg)
+ buf = fmt % arg
+ if six.PY3:
+ buf = buf.encode()
+ try:
+ os.write(1, buf)
except OSError as e:
if e.args[0] != errno.EPIPE: raise
sys.exit(1)
@@ -46,6 +51,8 @@ def main():
lines = _readlines(0)
if not lines: break
for line in lines:
+ if not isinstance(line, six.string_types):
+ line = line.decode('utf-8')
cnt += 1
opts = URLGrabberOptions()
opts._id = cnt