summaryrefslogtreecommitdiff
path: root/bin
diff options
authorJonathan Cave <jonathan.cave@canonical.com>2020-02-07 14:41:39 +0000
committerJonathan Cave <jonathan.cave@canonical.com>2020-02-07 14:41:39 +0000
commitc535c4606acf306825125de19b4e28b8a0e422cd (patch)
treea4862c75b9ee50ac457c6533b5c6ce2d947a571b /bin
parent42c65f8ab5810e3d8299974318bd9136532efafc (diff)
dmi-sysfs-resource: remove guacamole dependency
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dmi-sysfs-resource53
1 files changed, 25 insertions, 28 deletions
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 <zygmunt.krynicki@canonical.com>
+# Jonathan Cave <jonathan.cave@canonical.com>
"""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()