From 48ece81d0b235081f7b38a3303049cc149d59018 Mon Sep 17 00:00:00 2001 From: Jeff Lane Date: Tue, 18 Aug 2015 18:18:07 -0400 Subject: nitpic fixes --- bin/disk_info | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/disk_info b/bin/disk_info index 8b2cc0a..d32bc13 100755 --- a/bin/disk_info +++ b/bin/disk_info @@ -1,10 +1,9 @@ #!/usr/bin/env python3 # -# disk_info -# # This file is part of Checkbox. # -# Copyright 2015 Canonical Ltd. +# Copyright (C) 2010-2013 by Cloud Computing Center for Mobile Applications +# Industrial Technology Research Institute # # Authors: # Nelson Chu @@ -21,6 +20,12 @@ # # You should have received a copy of the GNU General Public License # along with Checkbox. If not, see . +""" +disk_info + +Uses lshw to gather information about disks seen by the OS. +Outputs logical name, vendor, description, size and product data +""" import sys import xml.etree.ElementTree as ET @@ -29,11 +34,9 @@ from subprocess import check_output def get_item(disk, attribute): try: - attribute_name = disk.find(attribute).text + return disk.find(attribute).text except AttributeError: - attribute_name = "Unknown" - - return attribute_name + return "Unknown" def main(): @@ -47,7 +50,6 @@ def main(): print("No disk information discovered.") return 10 - result = {} for disk in disk_list: if disk.get('id') == 'disk': print("Name: {}".format(get_item(disk, 'logicalname'))) @@ -60,7 +62,7 @@ def main(): try: disk_size = ("%dGB" % ( int(disk.find('size').text) / (1000**3))) - except: + except TypeError: disk_size = "Unknown" print("\t{k:15}\t{v}".format(k="Size:", v=disk_size)) -- cgit v1.2.3