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
1diff --git a/bin/get_make_and_model b/bin/get_make_and_model
2index bb5efd9..496a949 100755
3--- a/bin/get_make_and_model
4+++ b/bin/get_make_and_model
5@@ -4,31 +4,39 @@ import os.path
6 import shlex
7 from subprocess import check_output
8
9+def print_header(value):
10+ print("{}:".format(value))
11+
12 def print_data(key, value):
13- print("{}: {}".format(key, value))
14+ print(" {}: {}".format(key, value))
15+
16+def run_cmd(option):
17+ cmd = "lshw -C " + option
18+ out = check_output(shlex.split(cmd),
19+ universal_newlines = True)
20+ return out.split('\n')
21
22 def main():
23 keys = {'Manufacturer': 'vendor',
24 'Model': 'product',
25 'Version': 'version'}
26-
27- cmd = "lshw -C system"
28-
29- out = check_output(shlex.split(cmd),
30- universal_newlines = True)
31- output = out.split('\n')
32-
33- data = {}
34- for key in keys:
35- for line in output:
36- if keys[key] in line:
37- data[key] = line.split(':')[1].strip()
38- break
39- else:
40- data[key] = "NOT FOUND"
41-
42- for key in data:
43- print_data(key, data[key])
44+ lshw_classes = {'system': 'System',
45+ 'bus': 'Mainboard'}
46+
47+ for lshw_class in lshw_classes:
48+ output = run_cmd(lshw_class)
49+ data = {}
50+ for key in keys:
51+ for line in output:
52+ if keys[key] in line:
53+ data[key] = line.split(':')[1].strip()
54+ break
55+ else:
56+ data[key] = "NOT FOUND"
57+
58+ print_header(lshw_classes[lshw_class])
59+ for key in data:
60+ print_data(key, data[key])
61
62 if __name__ == "__main__":
63 raise SystemExit(main())

Subscribers

People subscribed via source and target branches