Skip to content

Commit 09f0c9d

Browse files
committed
Merge pull request geekcomputers#45 from frarteaga/master
To avoid AttributeError when linux_distribution is not present in platform module
2 parents 251b14e + b075274 commit 09f0c9d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

osinfo.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Script Name : osinfo.py
22
# Author : Craig Richards
33
# Created : 5th April 2012
4-
# Last Modified : 22nd February 2016
4+
# Last Modified : April 02 2016
55
# Version : 1.0
66

77
# Modifications : Changed the list to a dictionary. Although the order is lost, the info is with its label.
@@ -12,7 +12,7 @@
1212

1313
profile = {
1414
'Architecture: ': platform.architecture(),
15-
'Linux Distribution: ': platform.linux_distribution(),
15+
#'Linux Distribution: ': platform.linux_distribution(),
1616
'mac_ver: ': platform.mac_ver(),
1717
'machine: ': platform.machine(),
1818
'node: ': platform.node(),
@@ -27,5 +27,10 @@
2727
'version: ': platform.version(),
2828
}
2929

30+
if hasattr(platform, 'linux_distribution'):
31+
#to avoid AttributeError exception in some old versions of the module
32+
profile['linux_distribution'] = platform.linux_distribution()
33+
#FIXME: do this for all properties but in a loop
34+
3035
for key in profile:
3136
print(key + str(profile[key]))

0 commit comments

Comments
 (0)