From 176066d91708e9f382b84b7cd6eecb20928883a1 Mon Sep 17 00:00:00 2001 From: hakril Date: Sun, 10 May 2020 23:15:41 +0200 Subject: [PATCH] Added option --attributes to enum_device, and updated the sample accordingly --- .../device_manager_enum_devices.txt | 24 +++++++++++++++++-- samples/device_manager/enum_devices.py | 15 ++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/docs/source/samples_output/device_manager_enum_devices.txt b/docs/source/samples_output/device_manager_enum_devices.txt index 2ac649e..2f5b197 100644 --- a/docs/source/samples_output/device_manager_enum_devices.txt +++ b/docs/source/samples_output/device_manager_enum_devices.txt @@ -11,13 +11,33 @@ Namespace(clsfilter=None, no_print_devices=True, print_resources=False) .... -$ python64 device_manager\enum_devices.py --class Processor -Namespace(clsfilter='Processor', no_print_devices=False, print_resources=False) +$ python64 device_manager\enum_devices.py --class Processor --attributes name manufacturer device_object_name location_paths +Namespace(attributes=['name', 'manufacturer', 'device_object_name', 'location_paths'], clsfilter='Processor', no_print_devices=False, print_resources=False) * + Attributes: + * name=Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz + * manufacturer=Intel + * device_object_name=\Device\00000017 + * location_paths=[u'ACPI(_SB_)#ACPI(CPU0)'] * + Attributes: + * name=Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz + * manufacturer=Intel + * device_object_name=\Device\00000018 + * location_paths=[u'ACPI(_SB_)#ACPI(CPU1)'] * + Attributes: + * name=Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz + * manufacturer=Intel + * device_object_name=\Device\00000019 + * location_paths=[u'ACPI(_SB_)#ACPI(CPU2)'] * + Attributes: + * name=Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz + * manufacturer=Intel + * device_object_name=\Device\0000001a + * location_paths=[u'ACPI(_SB_)#ACPI(CPU3)'] $ python64 device_manager\enum_devices.py --class Display --print-resources diff --git a/samples/device_manager/enum_devices.py b/samples/device_manager/enum_devices.py index 19b7f0b..87b517c 100644 --- a/samples/device_manager/enum_devices.py +++ b/samples/device_manager/enum_devices.py @@ -12,7 +12,7 @@ def class_generator(filter=None): yield cls -def main(clsfilter, enumerate_devices, print_devinst_resources): +def main(clsfilter, enumerate_devices, print_devinst_resources, attributes): for devcls in class_generator(clsfilter): print(devcls) if not enumerate_devices: @@ -20,6 +20,14 @@ def main(clsfilter, enumerate_devices, print_devinst_resources): # Enumerate devices for devinst in devcls.devices: print(" * {0}".format(devinst)) + + # Print attributes + if attributes: + print(" Attributes:") + for attr in attributes: + value = getattr(devinst, attr) + print(" * {0}={1}".format(attr, value)) + if not print_devinst_resources: continue # Device resources @@ -28,6 +36,7 @@ def main(clsfilter, enumerate_devices, print_devinst_resources): # No allocated configuration # Check boot conf ? continue + for resource in devconf.resources: print(" * {0}".format(resource)) @@ -37,12 +46,14 @@ if __name__ == "__main__": parser.add_argument("--class", dest="clsfilter", default=None, help="The classe to list: default all") parser.add_argument("--no-print-devices", action="store_true", help="Prevent the listing of devices in the matching classes") parser.add_argument("--print-resources", action="store_true", help="Print the resources allocated to the device instance") + parser.add_argument("--attributes", nargs="+", help="The list of attributes to print for each discovered device instance") args = parser.parse_args() print(args) main(args.clsfilter, enumerate_devices=not args.no_print_devices, - print_devinst_resources=args.print_resources) + print_devinst_resources=args.print_resources, + attributes=args.attributes)