Merge ~emitorino/usn-tool:fix_usn_similarity_to_consider_old_usns into usn-tool:master

Proposed by Emilia Torino
Status: Merged
Merged at revision: 1311977c225c2b27078f52a8fc3f0d7aa4044e0b
Proposed branch: ~emitorino/usn-tool:fix_usn_similarity_to_consider_old_usns
Merge into: usn-tool:master
Diff against target: 22 lines (+8/-4)
1 file modified
usn.py (+8/-4)
Reviewer Review Type Date Requested Status
Alex Murray Approve
Review via email: mp+416099@code.launchpad.net

Commit message

- usn.py: check is sources key is present before comparing USNs in usn_similar

Description of the change

While trying to publish the updates to the USNs related to fixing terms which could be non-inclusive, usn.py failed to compare USNs when sources key is not present. This happens only with old USNs: 126-1, 149-1, 152-1, 155-1, 204-1, 30-1, 363-1, 412-1 and 483-1.

If needed we can add the sources to those USNs as well, but the check seems correct anyways for the script to not fail like it is failing now:

Traceback (most recent call last):
  File "/home/ubuntu-security/git-pulls/usn-tool/usn.py", line 699, in <module>
    output = main(sys.argv[1:])
  File "/home/ubuntu-security/git-pulls/usn-tool/usn.py", line 573, in main
    if key in database and not usn_similar(data[key], database[key]) != 0:
  File "/home/ubuntu-security/git-pulls/usn-tool/usn.py", line 549, in usn_similar
    if set(old['releases'][rel]['sources'].keys()) != set(new['releases'][rel]['sources'].keys()):
KeyError: 'sources'

To post a comment you must log in.
Revision history for this message
Alex Murray (alexmurray) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/usn.py b/usn.py
index 17fc033..673f3f2 100755
--- a/usn.py
+++ b/usn.py
@@ -546,11 +546,15 @@ def usn_similar(old, new):
546 if set(old['releases'].keys()) != set(new['releases'].keys()):546 if set(old['releases'].keys()) != set(new['releases'].keys()):
547 return False547 return False
548 for rel in old['releases'].keys():548 for rel in old['releases'].keys():
549 if set(old['releases'][rel]['sources'].keys()) != set(new['releases'][rel]['sources'].keys()):549 # Old USNs might not have the source packages information
550 return False550 if 'sources' in old['releases'][rel]:
551 for src in old['releases'][rel]['sources']:551 if set(old['releases'][rel]['sources'].keys()) != set(new['releases'][rel]['sources'].keys()):
552 if old['releases'][rel]['sources'][src]['version'] != new['releases'][rel]['sources'][src]['version']:
553 return False552 return False
553 for src in old['releases'][rel]['sources']:
554 if old['releases'][rel]['sources'][src]['version'] != new['releases'][rel]['sources'][src]['version']:
555 return False
556 else:
557 print("WARNING: no source packages information available in %s" % old["id"])
554 return True558 return True
555559
556560

Subscribers

People subscribed via source and target branches

to all changes: