2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007 Red Hat, Inc.
6 # This software may be freely redistributed under the terms of the GNU
7 # general public license.
9 # You should have received a copy of the GNU General Public License
10 # along with this program; if not, write to the Free Software
11 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13 from pykickstart
.base
import *
14 from pykickstart
.errors
import *
15 from pykickstart
.options
import *
17 from rhpl
.translate
import _
18 import rhpl
.translate
as translate
20 translate
.textdomain("pykickstart")
22 class FC3_RootPw(KickstartCommand
):
23 def __init__(self
, writePriority
=0, isCrypted
=False, password
=""):
24 KickstartCommand
.__init
__(self
, writePriority
)
25 self
.isCrypted
= isCrypted
26 self
.password
= password
29 if self
.password
!= "":
31 crypted
= "--iscrypted"
35 return "# Root password\nrootpw %s %s\n" % (crypted
, self
.password
)
39 def parse(self
, args
):
40 op
= KSOptionParser(lineno
=self
.lineno
)
41 op
.add_option("--iscrypted", dest
="isCrypted", action
="store_true",
44 (opts
, extra
) = op
.parse_args(args
=args
)
45 self
._setToSelf
(op
, opts
)
48 raise KickstartValueError
, formatErrorMsg(self
.lineno
, msg
=_("A single argument is expected for the %s command") % "rootpw")
50 self
.password
= extra
[0]
52 class F8_RootPw(FC3_RootPw
):
53 def __init__(self
, writePriority
=0, isCrypted
=False, password
="",
55 FC3_RootPw
.__init
__(self
, writePriority
, isCrypted
, password
)
59 retval
= FC3_RootPw
.__str
__(self
)
61 if retval
!= "" and self
.lock
:
62 return retval
.strip() + " --lock\n"
66 def parse(self
, args
):
67 op
= KSOptionParser(lineno
=self
.lineno
)
68 op
.add_option("--iscrypted", dest
="isCrypted", action
="store_true",
70 op
.add_option("--lock", dest
="lock", action
="store_true", default
=False)
71 op
.add_option("--plaintext", dest
="isCrypted", action
="store_false")
73 (opts
, extra
) = op
.parse_args(args
=args
)
74 self
._setToSelf
(op
, opts
)
77 raise KickstartValueError
, formatErrorMsg(self
.lineno
, msg
=_("A single argument is expected for the %s command") % "rootpw")
79 self
.password
= extra
[0]