-
Notifications
You must be signed in to change notification settings - Fork 2
/
lsb_release
executable file
·76 lines (64 loc) · 2.8 KB
/
lsb_release
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
76
#!/usr/bin/python3 -Es
# Fake lsb_release command
from optparse import OptionParser
import sys
def main():
parser = OptionParser()
parser.add_option('-v', '--version', dest='version', action='store_true',
default=False,
help="show LSB modules this system supports")
parser.add_option('-i', '--id', dest='id', action='store_true',
default=False,
help="show distributor ID")
parser.add_option('-d', '--description', dest='description',
default=False, action='store_true',
help="show description of this distribution")
parser.add_option('-r', '--release', dest='release',
default=False, action='store_true',
help="show release number of this distribution")
parser.add_option('-c', '--codename', dest='codename',
default=False, action='store_true',
help="show code name of this distribution")
parser.add_option('-a', '--all', dest='all',
default=False, action='store_true',
help="show all of the above information")
parser.add_option('-s', '--short', dest='short',
action='store_true', default=False,
help="show requested information in short format")
(options, args) = parser.parse_args()
if args:
parser.error("No arguments are permitted")
short = (options.short)
none = not (options.all or options.version or options.id or
options.description or options.codename or options.release)
distinfo = {'ID': 'Ubuntu', 'DESCRIPTION': 'Ubuntu 22.04', 'RELEASE': '22.04', 'CODENAME': 'jammy'}
if none or options.all or options.version:
verinfo = []
if not verinfo:
print("No LSB modules are available.", file=sys.stderr)
elif short:
print(':'.join(verinfo))
else:
print('LSB Version:\t' + ':'.join(verinfo))
if options.id or options.all:
if short:
print(distinfo.get('ID', 'n/a'))
else:
print('Distributor ID:\t%s' % distinfo.get('ID', 'n/a'))
if options.description or options.all:
if short:
print(distinfo.get('DESCRIPTION', 'n/a'))
else:
print('Description:\t%s' % distinfo.get('DESCRIPTION', 'n/a'))
if options.release or options.all:
if short:
print(distinfo.get('RELEASE', 'n/a'))
else:
print('Release:\t%s' % distinfo.get('RELEASE', 'n/a'))
if options.codename or options.all:
if short:
print(distinfo.get('CODENAME', 'n/a'))
else:
print('Codename:\t%s' % distinfo.get('CODENAME', 'n/a'))
if __name__ == '__main__':
main()