From b0752743cc968004d31b9a5283de1c2547d0cb47 Mon Sep 17 00:00:00 2001 From: Frank Arteaga Salgado Date: Sat, 2 Apr 2016 21:33:22 -0500 Subject: [PATCH] To avoid AttributeError when linux_distribution is not present in platform module modified: osinfo.py --- osinfo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osinfo.py b/osinfo.py index fc8a8a18d4a..a109901e80a 100644 --- a/osinfo.py +++ b/osinfo.py @@ -1,7 +1,7 @@ # Script Name : osinfo.py # Author : Craig Richards # Created : 5th April 2012 -# Last Modified : 22nd February 2016 +# Last Modified : April 02 2016 # Version : 1.0 # Modifications : Changed the list to a dictionary. Although the order is lost, the info is with its label. @@ -12,7 +12,7 @@ profile = { 'Architecture: ': platform.architecture(), -'Linux Distribution: ': platform.linux_distribution(), +#'Linux Distribution: ': platform.linux_distribution(), 'mac_ver: ': platform.mac_ver(), 'machine: ': platform.machine(), 'node: ': platform.node(), @@ -27,5 +27,10 @@ 'version: ': platform.version(), } +if hasattr(platform, 'linux_distribution'): + #to avoid AttributeError exception in some old versions of the module + profile['linux_distribution'] = platform.linux_distribution() + #FIXME: do this for all properties but in a loop + for key in profile: print(key + str(profile[key]))