diff options
| author | PMR <pmr@pmr-lander> | 2020-02-07 15:25:50 +0000 |
|---|---|---|
| committer | PMR <pmr@pmr-lander> | 2020-02-07 15:25:50 +0000 |
| commit | 280117421c8b7625ff112ed90ebfb430cb393692 (patch) | |
| tree | 99a47c267522a9f0510b432d9cf7a7278ac69352 | |
| parent | b39974045b2a8c8e354e29ed52e906cc66d68e41 (diff) | |
| parent | c53aff26ffef378b7ec6392dabd2015343af5b49 (diff) | |
Merge #378737 from ~jocave/plainbox-provider-checkbox:dmi-sys-deguac
| -rwxr-xr-x | bin/dmi-sysfs-resource | 46 | ||||
| -rwxr-xr-x | bin/dmi_sysfs_resource.py | 43 | ||||
| -rw-r--r-- | units/tpm/sysfs.pxu | 2 |
3 files changed, 44 insertions, 47 deletions
diff --git a/bin/dmi-sysfs-resource b/bin/dmi-sysfs-resource deleted file mode 100755 index 6741030..0000000 --- a/bin/dmi-sysfs-resource +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2015 Canonical Ltd. -# All rights reserved. -# -# Written by: -# Zygmunt Krynicki <zygmunt.krynicki@canonical.com> - -"""Collect information about all sysfs attributes related to DMI.""" - -import os - -import guacamole - - -class dmi_sysfs_resource(guacamole.Command): - - """ - Collect information about all sysfs attributes related to DMI. - - This program reads all the readable files in /sys/class/dmi/id/ and - presents them a single RFC822 record. - - @EPILOG@ - - Unreadable files (typically due to permissions) are silently skipped. - Please run this program as root if you wish to access various serial - numbers. - """ - - def invoked(self, ctx): - sysfs_root = '/sys/class/dmi/id/' - if not os.path.isdir(sysfs_root): - return - for dmi_attr in sorted(os.listdir(sysfs_root)): - dmi_filename = os.path.join(sysfs_root, dmi_attr) - if not os.path.isfile(dmi_filename): - continue - if not os.access(dmi_filename, os.R_OK): - continue - with open(dmi_filename, 'rt', encoding='utf-8') as stream: - dmi_data = stream.read().strip() - print("{}: {}".format(dmi_attr, dmi_data)) - - -if __name__ == "__main__": - dmi_sysfs_resource().main() diff --git a/bin/dmi_sysfs_resource.py b/bin/dmi_sysfs_resource.py new file mode 100755 index 0000000..a098976 --- /dev/null +++ b/bin/dmi_sysfs_resource.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# Copyright 2015-2020 Canonical Ltd. +# All rights reserved. +# +# Written by: +# Zygmunt Krynicki <zygmunt.krynicki@canonical.com> +# Jonathan Cave <jonathan.cave@canonical.com> + +"""Collect information about all sysfs attributes related to DMI.""" + +import os + +""" +Collect information about all sysfs attributes related to DMI. + +This program reads all the readable files in /sys/class/dmi/id/ and +presents them a single RFC822 record. + +@EPILOG@ + +Unreadable files (typically due to permissions) are silently skipped. +Please run this program as root if you wish to access various serial +numbers. +""" + + +def main(): + sysfs_root = '/sys/class/dmi/id/' + if not os.path.isdir(sysfs_root): + return + for dmi_attr in sorted(os.listdir(sysfs_root)): + dmi_filename = os.path.join(sysfs_root, dmi_attr) + if not os.path.isfile(dmi_filename): + continue + if not os.access(dmi_filename, os.R_OK): + continue + with open(dmi_filename, 'rt', encoding='utf-8') as stream: + dmi_data = stream.read().strip() + print("{}: {}".format(dmi_attr, dmi_data)) + + +if __name__ == "__main__": + 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: This job collects all the available DMI information from /sys/class/dmi/id/*. The main purpose of including this job is to allow the provider to include vendor-specific quirks by looking at the sysfs_dmi.bios_vendor attribute. -command: dmi-sysfs-resource +command: dmi_sysfs_resource.py estimated_duration: 1s flags: preserve-locale |
