-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestOpen.py
More file actions
29 lines (26 loc) · 966 Bytes
/
Copy pathtestOpen.py
File metadata and controls
29 lines (26 loc) · 966 Bytes
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
import os
def get_info():
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:')
return distinfo
if __name__ == '__main__':
info = get_info()
print info['DESCRIPTION']