|
1 | 1 | # Script Name : osinfo.py |
2 | | -# Author : Craig Richards |
3 | | -# Created : 5th April 2012 |
4 | | -# Last Modified : April 02 2016 |
5 | | -# Version : 1.0 |
6 | | - |
7 | | -# Modifications : Changed the list to a dictionary. Although the order is lost, the info is with its label. |
8 | | - |
9 | | -# Description : Displays some information about the OS you are running this script on |
10 | | - |
11 | | -import platform |
12 | | - |
13 | | -profile = { |
14 | | -'Architecture: ': platform.architecture(), |
15 | | -#'Linux Distribution: ': platform.linux_distribution(), |
16 | | -'mac_ver: ': platform.mac_ver(), |
17 | | -'machine: ': platform.machine(), |
18 | | -'node: ': platform.node(), |
19 | | -'platform: ': platform.platform(), |
20 | | -'processor: ': platform.processor(), |
21 | | -'python build: ': platform.python_build(), |
22 | | -'python compiler: ': platform.python_compiler(), |
23 | | -'python version: ': platform.python_version(), |
24 | | -'release: ': platform.release(), |
25 | | -'system: ': platform.system(), |
26 | | -'uname: ': platform.uname(), |
27 | | -'version: ': platform.version(), |
28 | | -} |
29 | | - |
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 |
| 2 | +# Authors : {'geekcomputers': 'Craig Richards', 'dmahugh': 'Doug Mahugh','rutvik1010':'Rutvik Narayana Nadimpally','y12uc231': 'Satyapriya Krishna', 'minto4644':'Mohit Kumar'} |
| 3 | +# Created : 5th April 2012 |
| 4 | +# Last Modified : July 19 2016 |
| 5 | +# Version : 1.0 |
| 6 | + |
| 7 | +# Modification 1 : Changed the profile to list again. Order is important. Everytime we run script we don't want to see different ordering. |
| 8 | +# Modification 2 : Fixed the AttributeError checking for all properties. Using hasttr(). |
| 9 | +# Modification 3 : Removed ': ' from properties inside profile. |
| 10 | + |
| 11 | + |
| 12 | +# Description : Displays some information about the OS you are running this script on |
| 13 | + |
| 14 | +import platform as pl |
| 15 | + |
| 16 | +profile = [ |
| 17 | +'architecture', |
| 18 | +'linux_distribution', |
| 19 | +'mac_ver', |
| 20 | +'machine', |
| 21 | +'node', |
| 22 | +'platform', |
| 23 | +'processor', |
| 24 | +'python_build', |
| 25 | +'python_compiler', |
| 26 | +'python_version', |
| 27 | +'release', |
| 28 | +'system', |
| 29 | +'uname', |
| 30 | +'version', |
| 31 | +] |
| 32 | + |
| 33 | + |
34 | 34 |
|
35 | 35 | for key in profile: |
36 | | - print(key + str(profile[key])) |
| 36 | + if hasattr(pl,key): |
| 37 | + print(key + ": "+ str(getattr(pl,key)())) |
| 38 | + |
0 commit comments