Accept --isUtc for backwards compatibility.
[pykickstart.git] / validator / ksvalidator
blob157f9172da30598f48cac452fb93930c3bc4900c
1 #!/usr/bin/python2
3 # Chris Lumens <clumens@redhat.com>
5 # Copyright 2005, 2006 Red Hat, Inc.
7 # This software may be freely redistributed under the terms of the GNU
8 # general public license.
10 # You should have received a copy of the GNU General Public License
11 # along with this program; if not, write to the Free Software
12 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 import optparse
16 import os
17 import sys
18 import warnings
19 from pykickstart.data import *
20 from pykickstart.parser import *
22 from rhpl.translate import _
23 import rhpl.translate as translate
25 translate.textdomain("pykickstart")
27 op = OptionParser(usage="usage: %prog [options] ksfile")
28 op.add_option("-e", "--firsterror", dest="firsterror", action="store_true",
29               default=False, help=_("halt after the first error or warning"))
30 op.add_option("-i", "--followincludes", dest="followincludes",
31               action="store_true", default=False,
32               help=_("parse include files when %include is seen"))
34 (opts, extra) = op.parse_args(sys.argv[1:])
36 if len(extra) != 1:
37     op.print_help()
38     os._exit(1)
39 else:
40     f = extra[0]
42 ksdata = KickstartData()
43 kshandlers = KickstartHandlers(ksdata)
44 ksparser = KickstartParser(ksdata, kshandlers,
45                            followIncludes=opts.followincludes,
46                            errorsAreFatal=opts.firsterror)
48 # turn DeprecationWarnings into errors
49 warnings.filterwarnings("error")
51 try:
52     ksparser.readKickstart(f)
53 except DeprecationWarning, msg:
54     print _("File uses a deprecated option or command.\n%s") % msg
55     os._exit(1)
56 except (KickstartParseError, KickstartValueError), msg:
57     print msg
58     os._exit(1)
59 except KickstartError:
60     print _("General kickstart error in input file")
61     os._exit(1)
62 except Exception, e:
63     print _("General error in input file:  %s") % e
64     os._exit(1)
66 os._exit(0)