Skip to content

To avoid AttributeError when linux_distribution is not present in platform module #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions osinfo.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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(),
Expand All @@ -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]))