2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
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.
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.
20 from pykickstart
.base
import KickstartCommand
21 from pykickstart
.errors
import KickstartValueError
, formatErrorMsg
22 from pykickstart
.options
import KSOptionParser
25 _
= lambda x
: gettext
.ldgettext("pykickstart", x
)
27 class FC3_XConfig(KickstartCommand
):
28 removedKeywords
= KickstartCommand
.removedKeywords
29 removedAttrs
= KickstartCommand
.removedAttrs
31 def __init__(self
, writePriority
=0, *args
, **kwargs
):
32 KickstartCommand
.__init
__(self
, writePriority
, *args
, **kwargs
)
33 self
.op
= self
._getParser
()
35 self
.card
= kwargs
.get("card", "")
36 self
.defaultdesktop
= kwargs
.get("defaultdesktop", "")
37 self
.depth
= kwargs
.get("depth", 0)
38 self
.hsync
= kwargs
.get("hsync", "")
39 self
.monitor
= kwargs
.get("monitor", "")
40 self
.noProbe
= kwargs
.get("noProbe", False)
41 self
.resolution
= kwargs
.get("resolution", "")
42 self
.server
= kwargs
.get("server", "")
43 self
.startX
= kwargs
.get("startX", False)
44 self
.videoRam
= kwargs
.get("videoRam", "")
45 self
.vsync
= kwargs
.get("vsync", "")
48 retval
= KickstartCommand
.__str
__(self
)
51 retval
+= " --card=%s" % self
.card
52 if self
.defaultdesktop
!= "":
53 retval
+= " --defaultdesktop=%s" % self
.defaultdesktop
55 retval
+= " --depth=%d" % self
.depth
57 retval
+= " --hsync=%s" % self
.hsync
58 if self
.monitor
!= "":
59 retval
+= " --monitor=%s" % self
.monitor
61 retval
+= " --noprobe"
62 if self
.resolution
!= "":
63 retval
+= " --resolution=%s" % self
.resolution
65 retval
+= " --server=%s" % self
.server
67 retval
+= " --startxonboot"
68 if self
.videoRam
!= "":
69 retval
+= " --videoram=%s" % self
.videoRam
71 retval
+= " --vsync=%s" % self
.vsync
74 retval
= "# X Window System configuration information\nxconfig %s\n" % retval
80 op
.add_option("--card")
81 op
.add_option("--defaultdesktop")
82 op
.add_option("--depth", action
="store", type="int", nargs
=1)
83 op
.add_option("--hsync")
84 op
.add_option("--monitor")
85 op
.add_option("--noprobe", dest
="noProbe", action
="store_true",
87 op
.add_option("--resolution")
88 op
.add_option("--server")
89 op
.add_option("--startxonboot", dest
="startX", action
="store_true",
91 op
.add_option("--videoram", dest
="videoRam")
92 op
.add_option("--vsync")
95 def parse(self
, args
):
96 (opts
, extra
) = self
.op
.parse_args(args
=args
, lineno
=self
.lineno
)
98 mapping
= {"command": "xconfig", "options": extra
}
99 raise KickstartValueError(formatErrorMsg(self
.lineno
, msg
=_("Unexpected arguments to %(command)s command: %(options)s") % mapping
))
101 self
._setToSelf
(self
.op
, opts
)
104 class FC6_XConfig(FC3_XConfig
):
105 removedKeywords
= FC3_XConfig
.removedKeywords
+ ["card", "hsync", "monitor", "noProbe", "vsync"]
106 removedAttrs
= FC3_XConfig
.removedAttrs
+ ["card", "hsync", "monitor", "noProbe", "vsync"]
108 def __init__(self
, writePriority
=0, *args
, **kwargs
):
109 FC3_XConfig
.__init
__(self
, writePriority
, *args
, **kwargs
)
110 self
.deleteRemovedAttrs()
112 self
.driver
= kwargs
.get("driver", "")
115 retval
= KickstartCommand
.__str
__(self
)
117 if hasattr(self
, "driver") and self
.driver
!= "":
118 retval
+= " --driver=%s" % self
.driver
119 if self
.defaultdesktop
!= "":
120 retval
+= " --defaultdesktop=%s" % self
.defaultdesktop
122 retval
+= " --depth=%d" % self
.depth
123 if hasattr(self
, "resolution") and self
.resolution
!= "":
124 retval
+= " --resolution=%s" % self
.resolution
126 retval
+= " --startxonboot"
127 if hasattr(self
, "videoRam") and self
.videoRam
!= "":
128 retval
+= " --videoram=%s" % self
.videoRam
131 retval
= "# X Window System configuration information\nxconfig %s\n" % retval
135 def _getParser(self
):
136 op
= FC3_XConfig
._getParser
(self
)
137 op
.add_option("--card", deprecated
=1)
138 op
.add_option("--driver", dest
="driver")
139 op
.add_option("--hsync", deprecated
=1)
140 op
.add_option("--monitor", deprecated
=1)
141 op
.add_option("--noprobe", deprecated
=1)
142 op
.add_option("--vsync", deprecated
=1)
145 class F9_XConfig(FC6_XConfig
):
146 removedKeywords
= FC6_XConfig
.removedKeywords
147 removedAttrs
= FC6_XConfig
.removedAttrs
149 def _getParser(self
):
150 op
= FC6_XConfig
._getParser
(self
)
151 op
.remove_option("--card")
152 op
.remove_option("--hsync")
153 op
.remove_option("--monitor")
154 op
.remove_option("--noprobe")
155 op
.remove_option("--vsync")
158 class F10_XConfig(F9_XConfig
):
159 removedKeywords
= F9_XConfig
.removedKeywords
+ ["driver", "resolution", "videoRam"]
160 removedAttrs
= F9_XConfig
.removedAttrs
+ ["driver", "resolution", "videoRam"]
162 def __init__(self
, writePriority
=0, *args
, **kwargs
):
163 F9_XConfig
.__init
__(self
, writePriority
, *args
, **kwargs
)
164 self
.deleteRemovedAttrs()
166 def _getParser(self
):
167 op
= F9_XConfig
._getParser
(self
)
168 op
.add_option("--driver", deprecated
=1)
169 op
.add_option("--depth", deprecated
=1)
170 op
.add_option("--resolution", deprecated
=1)
171 op
.add_option("--videoram", deprecated
=1)
174 class F14_XConfig(F10_XConfig
):
175 removedKeywords
= F10_XConfig
.removedKeywords
176 removedAttrs
= F10_XConfig
.removedAttrs
178 def _getParser(self
):
179 op
= F10_XConfig
._getParser
(self
)
180 op
.remove_option("--driver")
181 op
.remove_option("--depth")
182 op
.remove_option("--resolution")
183 op
.remove_option("--videoram")