From 1e8d7b130e82d5ec170fa6cba1f0e068ecfefe50 Mon Sep 17 00:00:00 2001 From: "Taihsiang Ho (tai271828)" Date: Tue, 23 Jan 2018 20:13:55 +0800 Subject: Compatible with Trusty to get net dirver info --- bin/net_driver_info | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/net_driver_info b/bin/net_driver_info index ee5db46..0eb5a83 100755 --- a/bin/net_driver_info +++ b/bin/net_driver_info @@ -1,9 +1,10 @@ #!/usr/bin/env python3 -# Copyright 2017 Canonical Ltd. +# Copyright 2017-2018 Canonical Ltd. # All rights reserved. # # Written by: # Jonathan Cave +# Taihsiang Ho # # Print info about drivers we can identify automatically and also those we # identify in the special interest list! @@ -28,7 +29,6 @@ for user_driver in sys.argv[1:]: driver_list.append(("unknown", user_driver)) else: print("Requested driver {} not loaded\n".format(user_driver)) - # Produce the output for interface, driver in driver_list: print("Interface {} using module {}".format(interface, driver)) @@ -37,5 +37,8 @@ for interface, driver in driver_list: print(" Parameters:") for path in Path(sysfs_path).iterdir(): if path.is_file(): - print(" {}: {}".format(path.name, path.read_text().strip())) + # Path.read_text is new in python 3.5 but we want to support + # trusty as well, which uses python 3.4 by default. + with open(str(path), 'r') as f: + print(" {}: {}".format(path.name, f.read().strip())) print() -- cgit v1.2.3