3
# lsb_release command for Debian
4
# (C) 2005-10 Chris Lawrence <lawrencc@debian.org>
6
# This package is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; version 2 dated June, 1991.
10
# This package is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this package; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
# Python3-compatible print() function
21
from __future__ import print_function
23
from optparse import OptionParser
31
parser = OptionParser()
32
parser.add_option('-v', '--version', dest='version', action='store_true',
34
help="show LSB modules this system supports")
35
parser.add_option('-i', '--id', dest='id', action='store_true',
37
help="show distributor ID")
38
parser.add_option('-d', '--description', dest='description',
39
default=False, action='store_true',
40
help="show description of this distribution")
41
parser.add_option('-r', '--release', dest='release',
42
default=False, action='store_true',
43
help="show release number of this distribution")
44
parser.add_option('-c', '--codename', dest='codename',
45
default=False, action='store_true',
46
help="show code name of this distribution")
47
parser.add_option('-a', '--all', dest='all',
48
default=False, action='store_true',
49
help="show all of the above information")
50
parser.add_option('-s', '--short', dest='short',
51
action='store_true', default=False,
52
help="show requested information in short format")
54
(options, args) = parser.parse_args()
56
parser.error("No arguments are permitted")
58
short = (options.short)
59
none = not (options.all or options.version or options.id or
60
options.description or options.codename or options.release)
62
distinfo = lsb_release.get_distro_information()
64
if none or options.all or options.version:
65
verinfo = lsb_release.check_modules_installed()
67
print("No LSB modules are available.", file=sys.stderr)
69
print(':'.join(verinfo))
71
print('LSB Version:\t' + ':'.join(verinfo))
73
if options.id or options.all:
75
print(distinfo.get('ID', 'n/a'))
77
print('Distributor ID:\t%s' % distinfo.get('ID', 'n/a'))
79
if options.description or options.all:
81
print(distinfo.get('DESCRIPTION', 'n/a'))
83
print('Description:\t%s' % distinfo.get('DESCRIPTION', 'n/a'))
85
if options.release or options.all:
87
print(distinfo.get('RELEASE', 'n/a'))
89
print('Release:\t%s' % distinfo.get('RELEASE', 'n/a'))
91
if options.codename or options.all:
93
print(distinfo.get('CODENAME', 'n/a'))
95
print('Codename:\t%s' % distinfo.get('CODENAME', 'n/a'))
97
if __name__ == '__main__':