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
1diff --git a/usn.py b/usn.py
2index 17fc033..673f3f2 100755
3--- a/usn.py
4+++ b/usn.py
5@@ -546,11 +546,15 @@ def usn_similar(old, new):
6 if set(old['releases'].keys()) != set(new['releases'].keys()):
7 return False
8 for rel in old['releases'].keys():
9- if set(old['releases'][rel]['sources'].keys()) != set(new['releases'][rel]['sources'].keys()):
10- return False
11- for src in old['releases'][rel]['sources']:
12- if old['releases'][rel]['sources'][src]['version'] != new['releases'][rel]['sources'][src]['version']:
13+ # Old USNs might not have the source packages information
14+ if 'sources' in old['releases'][rel]:
15+ if set(old['releases'][rel]['sources'].keys()) != set(new['releases'][rel]['sources'].keys()):
16 return False
17+ for src in old['releases'][rel]['sources']:
18+ if old['releases'][rel]['sources'][src]['version'] != new['releases'][rel]['sources'][src]['version']:
19+ return False
20+ else:
21+ print("WARNING: no source packages information available in %s" % old["id"])
22 return True
23
24

Subscribers

People subscribed via source and target branches

to all changes: