Tizen 2.1 base
[platform/upstream/lsb.git] / lsb_release
1 #!/usr/bin/python
2
3 # lsb_release command for Debian
4 # (C) 2005-08 Chris Lawrence <lawrencc@debian.org>
5
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.
9
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.
14
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
18 #    02111-1307, USA.
19
20 from optparse import OptionParser
21 import sys
22 import commands
23 import os
24 import re
25
26 import lsb_release
27
28 def main():
29     parser = OptionParser()
30     parser.add_option('-v', '--version', dest='version', action='store_true',
31                       default=False,
32                       help="show LSB modules this system supports")
33     parser.add_option('-i', '--id', dest='id', action='store_true',
34                       default=False,
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")
51     
52     (options, args) = parser.parse_args()
53     if args:
54         parser.error("No arguments are permitted")
55
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)
59
60     distinfo = lsb_release.get_distro_information()
61
62     if none or options.all or options.version:
63         verinfo = lsb_release.check_modules_installed()
64         if not verinfo:
65             print >> sys.stderr, "No LSB modules are available."
66         elif short:
67             print ':'.join(verinfo)
68         else:
69             print 'LSB Version:\t' + ':'.join(verinfo)
70
71     if options.id or options.all:
72         if short:
73             print distinfo.get('ID', 'n/a')
74         else:
75             print 'Distributor ID:\t%s' % distinfo.get('ID', 'n/a')
76
77     if options.description or options.all:
78         if short:
79             print distinfo.get('DESCRIPTION', 'n/a')
80         else:
81             print 'Description:\t%s' % distinfo.get('DESCRIPTION', 'n/a')
82
83     if options.release or options.all:
84         if short:
85             print distinfo.get('RELEASE', 'n/a')
86         else:
87             print 'Release:\t%s' % distinfo.get('RELEASE', 'n/a')
88
89     if options.codename or options.all:
90         if short:
91             print distinfo.get('CODENAME', 'n/a')
92         else:
93             print 'Codename:\t%s' % distinfo.get('CODENAME', 'n/a')
94
95 if __name__ == '__main__':
96     main()