diff options
| author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:38:32 +0100 |
|---|---|---|
| committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:50:20 +0100 |
| commit | e2e6f6fe07049f33cb6348780fa975162752e421 (patch) | |
| tree | b1813295411235d1297a0ed642b1346b24fdfb12 /scripts/lib/mic/kickstart/custom_commands/desktop.py | |
| download | poky-e2e6f6fe07049f33cb6348780fa975162752e421.tar.gz | |
initial commit of Enea Linux 3.1
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'scripts/lib/mic/kickstart/custom_commands/desktop.py')
| -rw-r--r-- | scripts/lib/mic/kickstart/custom_commands/desktop.py | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/scripts/lib/mic/kickstart/custom_commands/desktop.py b/scripts/lib/mic/kickstart/custom_commands/desktop.py new file mode 100644 index 0000000000..c8bd647ae3 --- /dev/null +++ b/scripts/lib/mic/kickstart/custom_commands/desktop.py | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | #!/usr/bin/python -tt | ||
| 2 | # | ||
| 3 | # Copyright (c) 2008, 2009, 2010 Intel, Inc. | ||
| 4 | # | ||
| 5 | # Yi Yang <yi.y.yang@intel.com> | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify it | ||
| 8 | # under the terms of the GNU General Public License as published by the Free | ||
| 9 | # Software Foundation; version 2 of the License | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, but | ||
| 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 13 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | # for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License along | ||
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
| 18 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 19 | |||
| 20 | from pykickstart.base import * | ||
| 21 | from pykickstart.errors import * | ||
| 22 | from pykickstart.options import * | ||
| 23 | |||
| 24 | class Mic_Desktop(KickstartCommand): | ||
| 25 | def __init__(self, writePriority=0, | ||
| 26 | defaultdesktop=None, | ||
| 27 | defaultdm=None, | ||
| 28 | autologinuser=None, | ||
| 29 | session=None): | ||
| 30 | |||
| 31 | KickstartCommand.__init__(self, writePriority) | ||
| 32 | |||
| 33 | self.__new_version = False | ||
| 34 | self.op = self._getParser() | ||
| 35 | |||
| 36 | self.defaultdesktop = defaultdesktop | ||
| 37 | self.autologinuser = autologinuser | ||
| 38 | self.defaultdm = defaultdm | ||
| 39 | self.session = session | ||
| 40 | |||
| 41 | def __str__(self): | ||
| 42 | retval = "" | ||
| 43 | |||
| 44 | if self.defaultdesktop != None: | ||
| 45 | retval += " --defaultdesktop=%s" % self.defaultdesktop | ||
| 46 | if self.session != None: | ||
| 47 | retval += " --session=\"%s\"" % self.session | ||
| 48 | if self.autologinuser != None: | ||
| 49 | retval += " --autologinuser=%s" % self.autologinuser | ||
| 50 | if self.defaultdm != None: | ||
| 51 | retval += " --defaultdm=%s" % self.defaultdm | ||
| 52 | |||
| 53 | if retval != "": | ||
| 54 | retval = "# Default Desktop Settings\ndesktop %s\n" % retval | ||
| 55 | |||
| 56 | return retval | ||
| 57 | |||
| 58 | def _getParser(self): | ||
| 59 | try: | ||
| 60 | op = KSOptionParser(lineno=self.lineno) | ||
| 61 | except TypeError: | ||
| 62 | # the latest version has not lineno argument | ||
| 63 | op = KSOptionParser() | ||
| 64 | self.__new_version = True | ||
| 65 | |||
| 66 | op.add_option("--defaultdesktop", dest="defaultdesktop", | ||
| 67 | action="store", | ||
| 68 | type="string", | ||
| 69 | nargs=1) | ||
| 70 | op.add_option("--autologinuser", dest="autologinuser", | ||
| 71 | action="store", | ||
| 72 | type="string", | ||
| 73 | nargs=1) | ||
| 74 | op.add_option("--defaultdm", dest="defaultdm", | ||
| 75 | action="store", | ||
| 76 | type="string", | ||
| 77 | nargs=1) | ||
| 78 | op.add_option("--session", dest="session", | ||
| 79 | action="store", | ||
| 80 | type="string", | ||
| 81 | nargs=1) | ||
| 82 | return op | ||
| 83 | |||
| 84 | def parse(self, args): | ||
| 85 | if self.__new_version: | ||
| 86 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 87 | else: | ||
| 88 | (opts, extra) = self.op.parse_args(args=args) | ||
| 89 | |||
| 90 | if extra: | ||
| 91 | m = _("Unexpected arguments to %(command)s command: %(options)s") \ | ||
| 92 | % {"command": "desktop", "options": extra} | ||
| 93 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=m) | ||
| 94 | |||
| 95 | self._setToSelf(self.op, opts) | ||
