Merge ~jocave/plainbox-provider-checkbox:dmi-sys-deguac into plainbox-provider-checkbox:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: 42cc6047e0a441908c25d8c1827d85cd5a15d236
Merged at revision: 4d86a1286815a7351f234107401abf0c65c7ee84
Proposed branch: ~jocave/plainbox-provider-checkbox:dmi-sys-deguac
Merge into: plainbox-provider-checkbox:master
Diff against target: 91 lines (+26/-29)
2 files modified
bin/dmi_sysfs_resource.py (+25/-28)
units/tpm/sysfs.pxu (+1/-1)
Reviewer Review Type Date Requested Status
Sheila Miguez (community) Approve
Review via email: mp+378737@code.launchpad.net

Description of the change

Continued effort to de-🥑 the provider, dmi-sysfs-resource.

To post a comment you must log in.
Revision history for this message
Sheila Miguez (codersquid) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/dmi-sysfs-resource b/bin/dmi_sysfs_resource.py
0similarity index 86%0similarity index 86%
1rename from bin/dmi-sysfs-resource1rename from bin/dmi-sysfs-resource
2rename to bin/dmi_sysfs_resource.py2rename to bin/dmi_sysfs_resource.py
index 6741030..a098976 100755
--- a/bin/dmi-sysfs-resource
+++ b/bin/dmi_sysfs_resource.py
@@ -1,46 +1,43 @@
1#!/usr/bin/env python31#!/usr/bin/env python3
2# Copyright 2015 Canonical Ltd.2# Copyright 2015-2020 Canonical Ltd.
3# All rights reserved.3# All rights reserved.
4#4#
5# Written by:5# Written by:
6# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>6# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
7# Jonathan Cave <jonathan.cave@canonical.com>
78
8"""Collect information about all sysfs attributes related to DMI."""9"""Collect information about all sysfs attributes related to DMI."""
910
10import os11import os
1112
12import guacamole13"""
14Collect information about all sysfs attributes related to DMI.
1315
16This program reads all the readable files in /sys/class/dmi/id/ and
17presents them a single RFC822 record.
1418
15class dmi_sysfs_resource(guacamole.Command):19@EPILOG@
1620
17 """21Unreadable files (typically due to permissions) are silently skipped.
18 Collect information about all sysfs attributes related to DMI.22Please run this program as root if you wish to access various serial
23numbers.
24"""
1925
20 This program reads all the readable files in /sys/class/dmi/id/ and
21 presents them a single RFC822 record.
2226
23 @EPILOG@27def main():
2428 sysfs_root = '/sys/class/dmi/id/'
25 Unreadable files (typically due to permissions) are silently skipped.29 if not os.path.isdir(sysfs_root):
26 Please run this program as root if you wish to access various serial30 return
27 numbers.31 for dmi_attr in sorted(os.listdir(sysfs_root)):
28 """32 dmi_filename = os.path.join(sysfs_root, dmi_attr)
2933 if not os.path.isfile(dmi_filename):
30 def invoked(self, ctx):34 continue
31 sysfs_root = '/sys/class/dmi/id/'35 if not os.access(dmi_filename, os.R_OK):
32 if not os.path.isdir(sysfs_root):36 continue
33 return37 with open(dmi_filename, 'rt', encoding='utf-8') as stream:
34 for dmi_attr in sorted(os.listdir(sysfs_root)):38 dmi_data = stream.read().strip()
35 dmi_filename = os.path.join(sysfs_root, dmi_attr)39 print("{}: {}".format(dmi_attr, dmi_data))
36 if not os.path.isfile(dmi_filename):
37 continue
38 if not os.access(dmi_filename, os.R_OK):
39 continue
40 with open(dmi_filename, 'rt', encoding='utf-8') as stream:
41 dmi_data = stream.read().strip()
42 print("{}: {}".format(dmi_attr, dmi_data))
4340
4441
45if __name__ == "__main__":42if __name__ == "__main__":
46 dmi_sysfs_resource().main()43 main()
diff --git a/units/tpm/sysfs.pxu b/units/tpm/sysfs.pxu
index fdbf390..a0c75dd 100644
--- a/units/tpm/sysfs.pxu
+++ b/units/tpm/sysfs.pxu
@@ -76,6 +76,6 @@ _description:
76 This job collects all the available DMI information from /sys/class/dmi/id/*.76 This job collects all the available DMI information from /sys/class/dmi/id/*.
77 The main purpose of including this job is to allow the provider to include77 The main purpose of including this job is to allow the provider to include
78 vendor-specific quirks by looking at the sysfs_dmi.bios_vendor attribute.78 vendor-specific quirks by looking at the sysfs_dmi.bios_vendor attribute.
79command: dmi-sysfs-resource79command: dmi_sysfs_resource.py
80estimated_duration: 1s80estimated_duration: 1s
81flags: preserve-locale81flags: preserve-locale

Subscribers

People subscribed via source and target branches