2 # Copyright (C) 2013 Red Hat, Inc.
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions of
6 # the GNU General Public License v.2, or (at your option) any later version.
7 # This program is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY expressed or implied, including the implied warranties of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10 # Public License for more details. You should have received a copy of the
11 # GNU General Public License along with this program; if not, write to the
12 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
13 # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
14 # source code or documentation are not subject to the GNU General Public
15 # License and may only be used or replicated with the express permission of
18 # Red Hat Author(s): Vratislav Podzimek <vpodzime@redhat.com>
21 from pykickstart
.base
import KickstartCommand
22 from pykickstart
.errors
import KickstartValueError
, formatErrorMsg
23 from pykickstart
.options
import KSOptionParser
26 _
= lambda x
: gettext
.ldgettext("pykickstart", x
)
28 class F20_Eula(KickstartCommand
):
29 """The 'eula' kickstart command"""
31 def __init__(self
, *args
, **kwargs
):
32 KickstartCommand
.__init
__(self
, *args
, **kwargs
)
33 self
.op
= self
._getParser
()
34 self
.agreed
= kwargs
.get("agreed", False)
37 retval
= KickstartCommand
.__str
__(self
)
40 retval
+= "# License agreement\n"
41 retval
+= "eula %s\n" % self
._getArgsAsStr
()
45 def _getArgsAsStr(self
):
53 # people would struggle remembering the exact word
54 op
.add_option("--agreed", "--agree", "--accepted", "--accept",
55 dest
="agreed", action
="store_true", default
=False)
59 def parse(self
, args
):
60 (opts
, extra
) = self
.op
.parse_args(args
=args
, lineno
=self
.lineno
)
61 self
._setToSelf
(self
.op
, opts
)
64 raise KickstartValueError(formatErrorMsg(self
.lineno
, msg
=_("Kickstart command %s does not take any arguments") % "eula"))
67 raise KickstartValueError(formatErrorMsg(self
.lineno
, msg
=_("Kickstart command eula expects the --agreed option")))