Merge ~bladernr/plainbox-provider-checkbox:1672726-improve-get-make-model into plainbox-provider-checkbox:master

Proposed by Jeff Lane 
Status: Merged
Approved by: Jeff Lane 
Approved revision: 15a136e32ae8efea3a6883babfdd87ad36ba0955
Merged at revision: 190c7ebd7eb3cf4d46311e42fa58dd8419aebe31
Proposed branch: ~bladernr/plainbox-provider-checkbox:1672726-improve-get-make-model
Merge into: plainbox-provider-checkbox:master
Diff against target: 63 lines (+27/-19)
1 file modified
bin/get_make_and_model (+27/-19)
Reviewer Review Type Date Requested Status
Pierre Equoy Approve
Review via email: mp+319847@code.launchpad.net

Description of the change

bin/get_make_and_model: Now also outputs info on the baseboard make and model to make indentifying systems like SuperMicro easier.

To post a comment you must log in.
Revision history for this message
Pierre Equoy (pieq) wrote :

I've tested this on my laptop.

Without the patch applied:

Manufacturer: Dell Inc.
Version: 01
Model: Latitude E5550 (Latitude E5550)

With the patch applied:

Mainboard:
  Manufacturer: Dell Inc.
  Version: A00
  Model: 013BI2
System:
  Manufacturer: Dell Inc.
  Version: 01
  Model: Latitude E5550 (Latitude E5550)

Looks good to me, but I'm wondering if the output of this script is not used in other parts that might be impacted by this change. I was for instance thinking of the C3 website, but when I check the page of the aforementioned laptop (https://certification.canonical.com/hardware/201409-15490/), it seems that the make/model data is not exactly the same anyway, so it probably gets this data from somewhere else.

I had a quick look and it seems this script has been introduced by Rod Smith and it's not called anywhere else other than in the miscellanea/get_make_and_model job, so it should be fine!

Added an inline comment too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/get_make_and_model b/bin/get_make_and_model
index bb5efd9..496a949 100755
--- a/bin/get_make_and_model
+++ b/bin/get_make_and_model
@@ -4,31 +4,39 @@ import os.path
4import shlex4import shlex
5from subprocess import check_output5from subprocess import check_output
66
7def print_header(value):
8 print("{}:".format(value))
9
7def print_data(key, value):10def print_data(key, value):
8 print("{}: {}".format(key, value))11 print(" {}: {}".format(key, value))
12
13def run_cmd(option):
14 cmd = "lshw -C " + option
15 out = check_output(shlex.split(cmd),
16 universal_newlines = True)
17 return out.split('\n')
918
10def main():19def main():
11 keys = {'Manufacturer': 'vendor',20 keys = {'Manufacturer': 'vendor',
12 'Model': 'product',21 'Model': 'product',
13 'Version': 'version'}22 'Version': 'version'}
1423 lshw_classes = {'system': 'System',
15 cmd = "lshw -C system"24 'bus': 'Mainboard'}
1625
17 out = check_output(shlex.split(cmd), 26 for lshw_class in lshw_classes:
18 universal_newlines = True)27 output = run_cmd(lshw_class)
19 output = out.split('\n')28 data = {}
20 29 for key in keys:
21 data = {}30 for line in output:
22 for key in keys:31 if keys[key] in line:
23 for line in output:32 data[key] = line.split(':')[1].strip()
24 if keys[key] in line:33 break
25 data[key] = line.split(':')[1].strip()34 else:
26 break35 data[key] = "NOT FOUND"
27 else:36
28 data[key] = "NOT FOUND"37 print_header(lshw_classes[lshw_class])
2938 for key in data:
30 for key in data:39 print_data(key, data[key])
31 print_data(key, data[key])
3240
33if __name__ == "__main__":41if __name__ == "__main__":
34 raise SystemExit(main())42 raise SystemExit(main())

Subscribers

People subscribed via source and target branches