[Piuparts-devel] [Git][debian/piuparts][develop] 4 commits: drop unused imports

Holger Levsen gitlab at salsa.debian.org
Tue Sep 10 13:35:32 BST 2019



Holger Levsen pushed to branch develop at Debian / piuparts


Commits:
dc410dd6 by Mattia Rizzolo at 2019-09-10T12:34:25Z
drop unused imports

Signed-off-by: Mattia Rizzolo <mattia at debian.org>
Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
46efe15c by Mattia Rizzolo at 2019-09-10T12:34:37Z
fix error handling, passing through the exception object correctly

before, httperror was already out of scope, so it couldn't be raised
again.

Signed-off-by: Mattia Rizzolo <mattia at debian.org>
Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
9838ed84 by Mattia Rizzolo at 2019-09-10T12:34:44Z
in py3 you can't raise a string, needs to wrap it in the Exception() class

Signed-off-by: Mattia Rizzolo <mattia at debian.org>
Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
d892e48e by Mattia Rizzolo at 2019-09-10T12:34:56Z
decode the file after reading it

At this point it would probably be best to completely rewrite that thing
using StringIO and some other nicer way to do buffering, but this should
do the job for now.

should fix:

09:46:14 Running section testing2sid (precedence=2)
Traceback (most recent call last):
  File "/srv/piuparts.debian.org/share/piuparts/piuparts-slave", line 1064, in <module>
    main()
  File "/srv/piuparts.debian.org/share/piuparts/piuparts-slave", line 1029, in main
    test_count += section.run(do_processing=(test_count == 0))
  File "/srv/piuparts.debian.org/share/piuparts/piuparts-slave", line 575, in run
    processed = self._process()
  File "/srv/piuparts.debian.org/share/piuparts/piuparts-slave", line 667, in _process
    packagenames)
  File "/srv/piuparts.debian.org/lib/python3/dist-packages/piupartslib/packagesdb.py", line 183, in load_packages_urls
    self._read_file(stream, restrict_packages=restrict_packages)
  File "/srv/piuparts.debian.org/lib/python3/dist-packages/piupartslib/packagesdb.py", line 190, in _read_file
    headers = rfc822_like_header_parse(input)
  File "/srv/piuparts.debian.org/lib/python3/dist-packages/piupartslib/packagesdb.py", line 53, in rfc822_like_header_parse
    line = input.readline()
  File "/srv/piuparts.debian.org/lib/python3/dist-packages/piupartslib/__init__.py", line 60, in readline
    empty = not self._refill()
  File "/srv/piuparts.debian.org/lib/python3/dist-packages/piupartslib/__init__.py", line 52, in _refill
    self._buffer = self._buffer + chunk
TypeError: can only concatenate str (not "bytes") to str

Signed-off-by: Mattia Rizzolo <mattia at debian.org>
Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


1 changed file:

- piupartslib/__init__.py


Changes:

=====================================
piupartslib/__init__.py
=====================================
@@ -21,10 +21,6 @@ import bz2
 import lzma
 import zlib
 
-from piupartslib import conf
-from piupartslib import dependencyparser
-from piupartslib import packagesdb
-
 from six.moves import urllib
 
 
@@ -49,6 +45,8 @@ class DecompressedStream():
                 return False
             if self._decompressor:
                 chunk = self._decompressor.decompress(chunk)
+            if isinstance(chunk, bytes):
+                chunk = chunk.decode()
             self._buffer = self._buffer + chunk
             if chunk:
                 return True
@@ -80,15 +78,16 @@ class DecompressedStream():
 def open_packages_url(url):
     """Open a Packages.bz2 file pointed to by a URL"""
     socket = None
+    error = None
     for ext in ['.xz', '.bz2', '.gz', '']:
         try:
             socket = urllib.request.urlopen(url + ext)
-        except urllib.error.HTTPError as httperror:
-            pass
+        except urllib.error.HTTPError as e:
+            error = e
         else:
             break
-    if socket is None:
-        raise httperror
+    else:
+        raise error
     url = socket.geturl()
     if ext == '.bz2':
         decompressor = bz2.BZ2Decompressor()
@@ -102,7 +101,7 @@ def open_packages_url(url):
     elif ext == '':
         decompressed = socket
     else:
-        raise ext
+        raise Exception('Unknown compression: {}'.format(ext))
     return (url, decompressed)
 
 # vi:set et ts=4 sw=4 :



View it on GitLab: https://salsa.debian.org/debian/piuparts/compare/65fa5d92b07f1ab559e582ff97400fc867c9d225...d892e48e2ca0ee8f529e8817a036511108e3cbdf

-- 
View it on GitLab: https://salsa.debian.org/debian/piuparts/compare/65fa5d92b07f1ab559e582ff97400fc867c9d225...d892e48e2ca0ee8f529e8817a036511108e3cbdf
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20190910/6b57271a/attachment-0001.html>


More information about the Piuparts-devel mailing list