-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetPlatform.py
More file actions
75 lines (68 loc) · 1.9 KB
/
Copy pathgetPlatform.py
File metadata and controls
75 lines (68 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import platform
import sys
import os
import re
import subprocess
def get_lsb_information():
distinfo = {}
if os.path.exists('/etc/lsb-release'):
try:
with open('/etc/lsb-release') as lsb_release_file:
for line in lsb_release_file:
line = line.strip()
if not line:
continue
# Skip invalid lines
if not '=' in line:
continue
var, arg = line.split('=', 1)
if var.startswith('DISTRIB_'):
var = var[8:]
if arg.startswith('"') and arg.endswith('"'):
arg = arg[1:-1]
if arg: # Ignore empty arguments
distinfo[var] = arg
except IOError as msg:
print('Unable to open /etc/lsb-release:', str(msg))
return distinfo
def get_distro_information():
lsbinfo = get_lsb_information()
# OS is only used inside guess_debian_release anyway
for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',):
if key not in lsbinfo:
distinfo = guess_debian_release()
distinfo.update(lsbinfo)
return distinfo
else:
return lsbinfo
def linux_distribution():
try:
return platform.linux_distribution()
except:
return "N/A"
if __name__ == '__main__':
os = platform.uname()
dist = platform.dist()
print(get_distro_information())
print dist[0]+' '+dist[1]
print os[2]
print("""Python version: %s
dist: %s
linux_distribution: %s
system: %s
machine: %s
platform: %s
uname: %s
version: %s
mac_ver: %s
""" % (
sys.version.split('\n'),
str(platform.dist()),
linux_distribution(),
platform.system(),
platform.machine(),
platform.platform(),
platform.uname(),
platform.version(),
platform.mac_ver(),
))