This is a partial revert of 1e20363.
When downloading a .diff.gz source package file, we do expect it to be
written to disk still compressed. If we were to uncompress it, then we
would get a size mismatch and even if we were to ignore that, we'd get a
hash mismatch.
On the other hand when downloading a changes file we need to make sure
that is written to disk uncompressed.
To make this work in both cases we can ask the HTTP server for no
special content encoding using "Accept-Encoding: identity". This is what
wget requests, for example. Then we can write the output to the file
without performing any decoding at our end by using the raw response
object again.
This fixes both cases.
LP: #2025748
pylint complains about C0209: Formatting a regular string which could be
a f-string (consider-using-f-string)
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint complains about W1201: Use lazy % formatting in logging functions
(logging-not-lazy) and W1203: Use lazy % formatting in logging functions
(logging-fstring-interpolation).
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Reading the raw stream doesn't decode files that are content-encoded,
which is true for the 'changes' file from launchpad, so it's saved
to disk gzipped which isn't what is expected.
Using the python requests iter_content method instead uses the
built-in stream decoding that the requests library provides, and
saves the file uncompressed/unencoded.
Note that since the encoded Content-Length won't match the resulting
unencoded actual length of data we save to file, this also turns off
the progress bar for any files that have Content-Encoding.
Update download() function to handle src of plain path, by prepending
'file://' to it. Also handle the case of src and dst pointing to the same
file.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
-require 'dst' parameter
-allow 'dst' parameter to be dir or dest file
-use contextlib.suppress instead of try/except/pass
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Allow specifying what package statuses should be searched for.
By default search only for Pending and Published, unless a specific
version number is being searched for.
- New drop-in replacement wrapper module around subprocess that
backports the restore_signals kwarg and defaults close_fds=True
- Switch everything previously using subprocess to use
ubuntutools.subprocess instead (LP: #785854)
- New drop-in replacement wrapper module around subprocess that
backports the restore_signals kwarg and defaults close_fds=True
- Switch everything previously using subprocess to use
ubuntutools.subprocess instead (LP: #785854)