[Simple-cdd-devel] Bug#861198: Shutting down public FTP services

Vagrant Cascadian vagrant at debian.org
Mon May 15 20:29:54 UTC 2017


On 2017-05-15, Vagrant Cascadian wrote:
> On 2017-05-15, Enrico Zini wrote:
>> On Mon, May 15, 2017 at 10:18:22AM -0700, Vagrant Cascadian wrote:
>>
>>>     File "/home/vagrant/simple-cdd/simple_cdd/utils.py", line 207, in verify_file
>>>       raise Fail("Invalid checksum for {}: expected {}, got {}", absname, hashsum, hasher.hexdigest())
>>>   simple_cdd.exceptions.Fail: <unprintable Fail object>
>>>   
>>>   During handling of the above exception, another exception occurred:
>>>   
>>>   Traceback (most recent call last):
>>>     File "/home/vagrant/simple-cdd/simple_cdd/log.py", line 85, in emit
>>>       record.message = record.getMessage()
>>>     File "/usr/lib/python3.5/logging/__init__.py", line 331, in getMessage
>>>       msg = msg % self.args
>>>   TypeError: not all arguments converted during string formatting
>>
>> Fail used %-formatting internally, but it was sometimes called with
>> printf-style format strings and sometimes with string.format style
>> format strings. I'm attaching a patch that unifies everything to
>> string.format-style strings.

Much shorter patch that switches the two cases of string.format style
format strings to printf-style %s/%d formatting:

diff --git a/simple_cdd/utils.py b/simple_cdd/utils.py
index e3a7370..df0ec50 100644
--- a/simple_cdd/utils.py
+++ b/simple_cdd/utils.py
@@ -183,7 +183,7 @@ class Checksums:
         if expected_size is not None:
             real_size = os.stat(absname).st_size
             if real_size != expected_size:
-                raise Fail("Invalid size for {}: expected {}, got {}", absname, expected_size, real_size)
+                raise Fail("Invalid size for %s: expected %d, got %d", absname, expected_size, real_size)
 
         # Check the file against the checksums that we have
         for hashtype in self.FIELDS:
@@ -204,7 +204,7 @@ class Checksums:
 
             # Verify
             if hasher.hexdigest() != hashsum:
-                raise Fail("Invalid checksum for {}: expected {}, got {}", absname, hashsum, hasher.hexdigest())
+                raise Fail("Invalid checksum for %s: expected %s, got %s", absname, hashsum, hasher.hexdigest())
 
     def parse_release_file(self, pathname):
         """

Seems to work! Any obvious problem with going that route?


live well,
  vagrant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/simple-cdd-devel/attachments/20170515/65869f9f/attachment-0001.sig>


More information about the Simple-cdd-devel mailing list