[Yum-devel] [PATCH 2/2] add URLGrabError.code to the external downloader API

Zdenek Pavlas zpavlas at redhat.com
Tue Apr 16 12:20:42 UTC 2013


---
 scripts/urlgrabber-ext-down | 2 +-
 urlgrabber/grabber.py       | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/urlgrabber-ext-down b/scripts/urlgrabber-ext-down
index 3dafb12..9ea0e70 100755
--- a/scripts/urlgrabber-ext-down
+++ b/scripts/urlgrabber-ext-down
@@ -68,7 +68,7 @@ def main():
                 ug_err = 'OK'
             except URLGrabError, e:
                 size = 0
-                ug_err = '%d %s' % e.args
+                ug_err = '%d %d %s' % (e.errno, getattr(e, 'code', 0), e.strerror)
             write('%d %d %d %.3f %s\n', opts._id, size, dlsz, dltm, ug_err)
 
 if __name__ == '__main__':
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index 9526dc1..66a1cf6 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -2052,7 +2052,7 @@ class _ExternalDownloader:
             raise KeyboardInterrupt
         for line in lines:
             # parse downloader output
-            line = line.split(' ', 5)
+            line = line.split(' ', 6)
             _id, size = map(int, line[:2])
             if len(line) == 2:
                 self.running[_id]._progress.update(size)
@@ -2063,7 +2063,8 @@ class _ExternalDownloader:
                 ug_err = None
                 if DEBUG: DEBUG.info('success')
             else:
-                ug_err = URLGrabError(int(line[4]), line[5])
+                ug_err = URLGrabError(int(line[4]), line[6])
+                ug_err.code = int(line[5])
                 if DEBUG: DEBUG.info('failure: %s', ug_err)
             _TH.update(opts.url, int(line[2]), float(line[3]), ug_err, opts.async[0])
             ret.append((opts, size, ug_err))
-- 
1.7.11.7



More information about the Yum-devel mailing list