Merge ~kissiel/checkbox-support:fix-1864709-lshw-yields-list into checkbox-support:master

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Rod Smith
Approved revision: 12ba6f4305d799d614ce7622da14ad0549ca9dc2
Merged at revision: 47631a7b95aea3a68bd957a3d0498e8ef71a506b
Proposed branch: ~kissiel/checkbox-support:fix-1864709-lshw-yields-list
Merge into: checkbox-support:master
Diff against target: 15 lines (+4/-0)
1 file modified
checkbox_support/parsers/lshwjson.py (+4/-0)
Reviewer Review Type Date Requested Status
Rod Smith Approve
Review via email: mp+379856@code.launchpad.net

Description of the change

lshw -json on focal yields a list of objects, which is considered a valid JSON, so I'm making this work as intended

To post a comment you must log in.
Revision history for this message
Rod Smith (rodsmith) wrote :

I've tested on both Ubuntu 18.04 and Ubuntu 20.04 pre-release, and it works on both.

Thanks for the quick fix, Maciej!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_support/parsers/lshwjson.py b/checkbox_support/parsers/lshwjson.py
2index c6ba382..9be6fb1 100644
3--- a/checkbox_support/parsers/lshwjson.py
4+++ b/checkbox_support/parsers/lshwjson.py
5@@ -31,6 +31,10 @@ class LshwJsonParser(object):
6 self.stream_or_string = stream_or_string
7
8 def _parse_lshw(self, lshw, result):
9+ if isinstance(lshw, list) and len(lshw) > 0:
10+ # newer lshw prints out list of JSON objects,
11+ # from what I found it is still one, so let use that one
12+ lshw = lshw[0]
13 if 'children' in lshw.keys():
14 for child in lshw['children']:
15 self._parse_lshw(child, result)

Subscribers

People subscribed via source and target branches