3 # Yi Yang <yi.y.yang@intel.com>
5 # Copyright 2008, 2009, 2010 Intel, Inc.
7 # This copyrighted material is made available to anyone wishing to use, modify,
8 # copy, or redistribute it subject to the terms and conditions of the GNU
9 # General Public License v.2. This program is distributed in the hope that it
10 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
17 # trademarks that are incorporated in the source code or documentation are not
18 # subject to the GNU General Public License and may only be used or replicated
19 # with the express permission of Red Hat, Inc.
21 from pykickstart.base import *
22 from pykickstart.errors import *
23 from pykickstart.options import *
25 class Moblin_Desktop(KickstartCommand):
26 def __init__(self, writePriority=0, defaultdesktop=None, defaultdm=None, autologinuser="meego", session="/usr/bin/mutter --sm-disable"):
27 KickstartCommand.__init__(self, writePriority)
29 self.__new_version = False
30 self.op = self._getParser()
32 self.defaultdesktop = defaultdesktop
33 self.autologinuser = autologinuser
34 self.defaultdm = defaultdm
35 self.session = session
40 if self.defaultdesktop != None:
41 retval += " --defaultdesktop=%s" % self.defaultdesktop
42 if self.session != None:
43 retval += " --session=\"%s\"" % self.session
44 if self.autologinuser != None:
45 retval += " --autologinuser=%s" % self.autologinuser
46 if self.defaultdm != None:
47 retval += " --defaultdm=%s" % self.defaultdm
50 retval = "# Default Desktop Settings\ndesktop %s\n" % retval
56 op = KSOptionParser(lineno=self.lineno)
58 # the latest version has not lineno argument
60 self.__new_version = True
62 op.add_option("--defaultdesktop", dest="defaultdesktop", action="store", type="string", nargs=1)
63 op.add_option("--autologinuser", dest="autologinuser", action="store", type="string", nargs=1)
64 op.add_option("--defaultdm", dest="defaultdm", action="store", type="string", nargs=1)
65 op.add_option("--session", dest="session", action="store", type="string", nargs=1)
68 def parse(self, args):
69 if self.__new_version:
70 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
72 (opts, extra) = self.op.parse_args(args=args)
75 mapping = {"command": "desktop", "options": extra}
76 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
78 self._setToSelf(self.op, opts)