daklib/command: avoid AttributeError when Uploader field is missing
Commit 495cf377 attempted to avoid crashes on invalid input, but in effect this seems to have made the Uploader field mandatory. Without it, the following happens:
Traceback (most recent call last):
File "/srv/ftp-master.debian.org/dak/dak/process_commands.py", line 76, in main
command.evaluate()
File "/srv/ftp-master.debian.org/dak/daklib/command.py", line 189, in evaluate
self._notify_uploader()
File "/srv/ftp-master.debian.org/dak/daklib/command.py", line 111, in _notify_uploader
if self.uploader:
AttributeError: 'CommandFile' object has no attribute 'uploader'
For some reason, there's no “uploader” attribute set in __init__(), and the aforementioned commit removed the “None” default value that was getting set in evaluate().
Set the default value directly in __init__(), fixing one of the two attribute-defined-outside-init pylint warnings (the “fingerprint” one remains).
WARNING: This is of course entirely untested, but I don't think it can really hurt given the current state…
As noted in the commit message, that leaves an attribute-defined-outside-init
pylint warning for fingerprint
but I don't think that's a practical issue since evaluate()
quickly calls:
self.fingerprint = session.query(Fingerprint).filter_by(fingerprint=signed_file.primary_fingerprint).one()
Feel free to refine the commit message as needed, I wanted to share as much information as possible; it might make sense to strip some of that. Or to just set self.uploader
at the top of evaluate()
if you prefer. Having said that, it seems that's not possible for a private project, but I'm happy to refine it myself following your feedback.
(Also seen with @dilinger's attempt to get someone else to upload chromium
— clever plan!)