From 42cc6047e0a441908c25d8c1827d85cd5a15d236 Mon Sep 17 00:00:00 2001 From: Jonathan Cave Date: Fri, 7 Feb 2020 14:43:17 +0000 Subject: dmi-sysfs-resource: script rename --- bin/dmi-sysfs-resource | 43 ------------------------------------------- bin/dmi_sysfs_resource.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) delete mode 100755 bin/dmi-sysfs-resource create mode 100755 bin/dmi_sysfs_resource.py (limited to 'bin') diff --git a/bin/dmi-sysfs-resource b/bin/dmi-sysfs-resource deleted file mode 100755 index a098976c..00000000 --- a/bin/dmi-sysfs-resource +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 -# 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 - -""" -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/bin/dmi_sysfs_resource.py b/bin/dmi_sysfs_resource.py new file mode 100755 index 00000000..a098976c --- /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 +# Jonathan Cave + +"""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() -- cgit v1.2.3