diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py | |
download | poky-c527fd1f14c27855a37f2e8ac5346ce8d940ced2.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py')
-rw-r--r-- | scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py b/scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py new file mode 100644 index 0000000000..200ccfba2e --- /dev/null +++ b/scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py | |||
@@ -0,0 +1,114 @@ | |||
1 | # | ||
2 | # Chris Lumens <clumens@redhat.com> | ||
3 | # | ||
4 | # Copyright 2005, 2006, 2007 Red Hat, Inc. | ||
5 | # | ||
6 | # This copyrighted material is made available to anyone wishing to use, modify, | ||
7 | # copy, or redistribute it subject to the terms and conditions of the GNU | ||
8 | # General Public License v.2. This program is distributed in the hope that it | ||
9 | # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the | ||
10 | # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
11 | # See the GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License along with | ||
14 | # this program; if not, write to the Free Software Foundation, Inc., 51 | ||
15 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat | ||
16 | # trademarks that are incorporated in the source code or documentation are not | ||
17 | # subject to the GNU General Public License and may only be used or replicated | ||
18 | # with the express permission of Red Hat, Inc. | ||
19 | # | ||
20 | from pykickstart.base import * | ||
21 | from pykickstart.errors import * | ||
22 | from pykickstart.options import * | ||
23 | |||
24 | class FC3_Vnc(KickstartCommand): | ||
25 | removedKeywords = KickstartCommand.removedKeywords | ||
26 | removedAttrs = KickstartCommand.removedAttrs | ||
27 | |||
28 | def __init__(self, writePriority=0, *args, **kwargs): | ||
29 | KickstartCommand.__init__(self, writePriority, *args, **kwargs) | ||
30 | self.op = self._getParser() | ||
31 | |||
32 | self.enabled = kwargs.get("enabled", False) | ||
33 | self.password = kwargs.get("password", "") | ||
34 | self.connect = kwargs.get("connect", "") | ||
35 | |||
36 | def __str__(self): | ||
37 | retval = KickstartCommand.__str__(self) | ||
38 | |||
39 | if not self.enabled: | ||
40 | return retval | ||
41 | |||
42 | retval += "vnc" | ||
43 | |||
44 | if self.connect != "": | ||
45 | retval += " --connect=%s" % self.connect | ||
46 | if self.password != "": | ||
47 | retval += " --password=%s" % self.password | ||
48 | |||
49 | return retval + "\n" | ||
50 | |||
51 | def _getParser(self): | ||
52 | op = KSOptionParser() | ||
53 | op.add_option("--connect") | ||
54 | op.add_option("--password", dest="password") | ||
55 | return op | ||
56 | |||
57 | def parse(self, args): | ||
58 | self.enabled = True | ||
59 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
60 | self._setToSelf(self.op, opts) | ||
61 | return self | ||
62 | |||
63 | class FC6_Vnc(FC3_Vnc): | ||
64 | removedKeywords = FC3_Vnc.removedKeywords + ["connect"] | ||
65 | removedAttrs = FC3_Vnc.removedAttrs + ["connect"] | ||
66 | |||
67 | def __init__(self, writePriority=0, host="", port="", *args, **kwargs): | ||
68 | FC3_Vnc.__init__(self, writePriority, *args, **kwargs) | ||
69 | self.deleteRemovedAttrs() | ||
70 | |||
71 | self.host = kwargs.get("host", "") | ||
72 | self.port = kwargs.get("port", "") | ||
73 | |||
74 | def __str__(self): | ||
75 | retval = KickstartCommand.__str__(self) | ||
76 | |||
77 | if not self.enabled: | ||
78 | return retval | ||
79 | |||
80 | retval += "vnc" | ||
81 | |||
82 | if self.host != "": | ||
83 | retval += " --host=%s" % self.host | ||
84 | |||
85 | if self.port != "": | ||
86 | retval += " --port=%s" % self.port | ||
87 | if self.password != "": | ||
88 | retval += " --password=%s" % self.password | ||
89 | |||
90 | return retval + "\n" | ||
91 | |||
92 | def _getParser(self): | ||
93 | def connect_cb (option, opt_str, value, parser): | ||
94 | cargs = value.split(":") | ||
95 | parser.values.ensure_value("host", cargs[0]) | ||
96 | |||
97 | if len(cargs) > 1: | ||
98 | parser.values.ensure_value("port", cargs[1]) | ||
99 | |||
100 | op = FC3_Vnc._getParser(self) | ||
101 | op.add_option("--connect", action="callback", callback=connect_cb, | ||
102 | nargs=1, type="string") | ||
103 | op.add_option("--host", dest="host") | ||
104 | op.add_option("--port", dest="port") | ||
105 | return op | ||
106 | |||
107 | class F9_Vnc(FC6_Vnc): | ||
108 | removedKeywords = FC6_Vnc.removedKeywords | ||
109 | removedAttrs = FC6_Vnc.removedAttrs | ||
110 | |||
111 | def _getParser(self): | ||
112 | op = FC6_Vnc._getParser(self) | ||
113 | op.remove_option("--connect") | ||
114 | return op | ||