3 # lsb_release command for Debian
4 # (C) 2005-08 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., 59 Temple Place - Suite 330, Boston, MA
20 from optparse import OptionParser
29 parser = OptionParser()
30 parser.add_option('-v', '--version', dest='version', action='store_true',
32 help="show LSB modules this system supports")
33 parser.add_option('-i', '--id', dest='id', action='store_true',
35 help="show distributor ID")
36 parser.add_option('-d', '--description', dest='description',
37 default=False, action='store_true',
38 help="show description of this distribution")
39 parser.add_option('-r', '--release', dest='release',
40 default=False, action='store_true',
41 help="show release number of this distribution")
42 parser.add_option('-c', '--codename', dest='codename',
43 default=False, action='store_true',
44 help="show code name of this distribution")
45 parser.add_option('-a', '--all', dest='all',
46 default=False, action='store_true',
47 help="show all of the above information")
48 parser.add_option('-s', '--short', dest='short',
49 action='store_true', default=False,
50 help="show requested information in short format")
52 (options, args) = parser.parse_args()
54 parser.error("No arguments are permitted")
56 short = (options.short)
57 none = not (options.all or options.version or options.id or
58 options.description or options.codename or options.release)
60 distinfo = lsb_release.get_distro_information()
62 if none or options.all or options.version:
63 verinfo = lsb_release.check_modules_installed()
65 print >> sys.stderr, "No LSB modules are available."
67 print ':'.join(verinfo)
69 print 'LSB Version:\t' + ':'.join(verinfo)
71 if options.id or options.all:
73 print distinfo.get('ID', 'n/a')
75 print 'Distributor ID:\t%s' % distinfo.get('ID', 'n/a')
77 if options.description or options.all:
79 print distinfo.get('DESCRIPTION', 'n/a')
81 print 'Description:\t%s' % distinfo.get('DESCRIPTION', 'n/a')
83 if options.release or options.all:
85 print distinfo.get('RELEASE', 'n/a')
87 print 'Release:\t%s' % distinfo.get('RELEASE', 'n/a')
89 if options.codename or options.all:
91 print distinfo.get('CODENAME', 'n/a')
93 print 'Codename:\t%s' % distinfo.get('CODENAME', 'n/a')
95 if __name__ == '__main__':