From c535c4606acf306825125de19b4e28b8a0e422cd Mon Sep 17 00:00:00 2001 From: Jonathan Cave Date: Fri, 7 Feb 2020 14:41:39 +0000 Subject: dmi-sysfs-resource: remove guacamole dependency --- bin/dmi-sysfs-resource | 53 ++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'bin') diff --git a/bin/dmi-sysfs-resource b/bin/dmi-sysfs-resource index 67410307..a098976c 100755 --- a/bin/dmi-sysfs-resource +++ b/bin/dmi-sysfs-resource @@ -1,46 +1,43 @@ #!/usr/bin/env python3 -# Copyright 2015 Canonical Ltd. +# Copyright 2015-2020 Canonical Ltd. # All rights reserved. # # Written by: # Zygmunt Krynicki +# Jonathan Cave """Collect information about all sysfs attributes related to DMI.""" import os -import guacamole +""" +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. -class dmi_sysfs_resource(guacamole.Command): +@EPILOG@ - """ - Collect information about all sysfs attributes related to DMI. +Unreadable files (typically due to permissions) are silently skipped. +Please run this program as root if you wish to access various serial +numbers. +""" - 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)) +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__": - dmi_sysfs_resource().main() + main() -- cgit v1.2.3