summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xanaconda7
-rw-r--r--desktop.py5
-rw-r--r--installclass.py4
-rw-r--r--instdata.py4
-rw-r--r--iw/xconfig_gui.py4
-rw-r--r--kbd.py4
-rw-r--r--language.py3
-rw-r--r--monitor.py269
-rw-r--r--mouse.py315
-rw-r--r--network.py2
-rw-r--r--simpleconfig.py49
-rw-r--r--textw/xconfig_text.py5
-rw-r--r--videocard.py579
-rw-r--r--xf86config.py4
-rw-r--r--xserver.py7
15 files changed, 27 insertions, 1234 deletions
diff --git a/anaconda b/anaconda
index e3560ee04..1cc26e3e7 100755
--- a/anaconda
+++ b/anaconda
@@ -275,11 +275,12 @@ if (debug):
import isys
import instdata
-import videocard
-import monitor
-import mouse
import floppy
+import rhpl.videocard as videocard
+import rhpl.monitor as monitor
+import rhpl.mouse as mouse
+
# handle traceonly and exit
if traceOnly:
diff --git a/desktop.py b/desktop.py
index 73923bedc..39ed5833f 100644
--- a/desktop.py
+++ b/desktop.py
@@ -3,7 +3,7 @@
#
# Matt Wilson <msw@redhat.com>
#
-# Copyright 2001 Red Hat, Inc.
+# Copyright 2001-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
@@ -14,9 +14,10 @@
#
import string
-from simpleconfig import SimpleConfigFile
+
from rhpl.log import log
+from rhpl.simpleconfig import SimpleConfigFile
class Desktop (SimpleConfigFile):
#
diff --git a/installclass.py b/installclass.py
index 115284b3f..833ead387 100644
--- a/installclass.py
+++ b/installclass.py
@@ -318,8 +318,8 @@ class BaseInstallClass:
def configureX(self, id, server = None, card = None, videoRam = None, monitorName = None, hsync = None, vsync = None, resolution = None, depth = None, noProbe = 0, startX = 0):
- import videocard
- import monitor
+ import rhpl.videocard
+ import rhpl.monitor
# XXX they could have sensitive hardware, but we need this info =\
diff --git a/instdata.py b/instdata.py
index 7553320ff..55a2a5a91 100644
--- a/instdata.py
+++ b/instdata.py
@@ -3,7 +3,7 @@
#
# Erik Troan <ewt@redhat.com>
#
-# Copyright 2001 Red Hat, Inc.
+# Copyright 2001-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
@@ -27,7 +27,7 @@ import partedUtils
from flags import *
from constants import *
-from simpleconfig import SimpleConfigFile
+from rhpl.simpleconfig import SimpleConfigFile
class Boolean:
def set(self, val):
diff --git a/iw/xconfig_gui.py b/iw/xconfig_gui.py
index c1b326614..5ed077f23 100644
--- a/iw/xconfig_gui.py
+++ b/iw/xconfig_gui.py
@@ -22,11 +22,11 @@ import gui
import gobject
import gtk
from iw_gui import *
-from monitor import isValidSyncRange
-from videocard import Videocard_blacklist
from rhpl.log import log
from rhpl.translate import _, N_
+from rhpl.monitor import isValidSyncRange
+from rhpl.videocard import Videocard_blacklist
ddc_monitor_string = _("DDC Probed Monitor")
unprobed_monitor_string = _("Unprobed Monitor")
diff --git a/kbd.py b/kbd.py
index 8a88359aa..5ecaf0175 100644
--- a/kbd.py
+++ b/kbd.py
@@ -3,7 +3,7 @@
#
# Mike Fulbright <msf@redhat.com>
#
-# Copyright 1999-2001 Red Hat, Inc.
+# Copyright 1999-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
@@ -15,9 +15,9 @@
import kudzu
import string
-from simpleconfig import SimpleConfigFile
from rhpl.log import log
+from rhpl.simpleconfig import SimpleConfigFile
class Keyboard (SimpleConfigFile):
# the *first* item in each of these wins conflicts
diff --git a/language.py b/language.py
index 1cf8eedfa..2d5d062e0 100644
--- a/language.py
+++ b/language.py
@@ -16,9 +16,10 @@
import os
import string
import locale
-from simpleconfig import SimpleConfigFile
import rpm
+
from rhpl.translate import cat
+from rhpl.simpleconfig import SimpleConfigFile
# Converts a single language into a "language search path". For example,
# fr_FR.utf8@euro would become "fr_FR.utf8@eueo fr_FR.utf8 fr_FR fr"
diff --git a/monitor.py b/monitor.py
deleted file mode 100644
index 53d074f12..000000000
--- a/monitor.py
+++ /dev/null
@@ -1,269 +0,0 @@
-#
-# monitor.py - monitor probing and install data
-#
-# Mike Fulbright <msf@redhat.com>
-#
-# Copyright 2001-2002 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-import string
-import kudzu
-
-from rhpl.log import log
-from rhpl.translate import _
-
-def isValidSyncRange(syncrange):
-
- def isValidPiece(piece):
- tmp = string.split(piece, "-")
- if len(tmp) > 2:
- return 0
-
- for i in tmp:
- try:
- tmp2 = float(i)
- except ValueError:
- return 0
-
- return 1
-
- pieces = string.split(syncrange, ",")
- for piece in pieces:
- if not isValidPiece(piece):
- return 0
-
- return 1
-
-
-
-class MonitorInfo:
-
-#
-# This class represents the monitor on the system. Values from ddcprobing
-# are provided if available. LCDs are not currently probed.
-#
-# Internal members (use methods to access):
-#
-# monEisa - probed monitor ID (string)
-# monName - human readable description (string)
-# monID - human readable ID (string)
-# fbmonSect - if framebuffer running, monitor ID (string)
-# monHoriz - horizontal rating (kHz)
-# monVert - vertical rating (Hz)
-#
- def readMonitorsDB (self, lines = None):
- if self.monlist:
- return self.monlist
- if not lines:
- db = open ('/usr/share/hwdata/MonitorsDB')
- lines = db.readlines ()
- db.close ()
-
- for line in lines:
- line = string.strip (line)
- if not line:
- continue
- if line and line[0] == '#':
- continue
- fields = string.split (line, ';')
- if len(fields) < 5:
- log("Bad MonitorsDB entry\n: %s", line)
- continue
- man = string.strip(fields[0])
- model = string.strip(fields[1])
- eisa = string.lower(string.strip(fields[2]))
- horiz = string.strip(fields[3])
- vert = string.strip(fields[4])
- if self.monlist.has_key(man):
- self.monlist[man].append((model, eisa, vert, horiz))
- else:
- self.monlist[man] = [(model, eisa, vert, horiz)]
- self.monids[eisa] = (man, model, eisa, vert, horiz)
- return self.monlist
-
- def monitorsDB(self):
- if not self.monlist:
- self.readMonitorsDB()
-
- return self.monlist
-
- def monitorsEISADB(self):
- if not self.monlist:
- self.readMonitorsDB()
-
- return self.monids
-
- def lookupMonitorByID(self, monID):
- if not self.monlist:
- self.readMonitorsDB()
-
- for man in self.monlist.keys():
- for model in self.monlist[man]:
- idlower = string.lower(monID)
- idupper = string.upper(monID)
- if idlower == model[1] or idupper == model[1]:
- return model
-
- return 0
-
- def lookupMonitorByName(self, monName):
- if not self.monlist:
- self.readMonitorsDB()
-
- for man in self.monlist.keys():
- for model in self.monlist[man]:
- if monName == model[0]:
- return model
-
- return None
-
-
- def __str__ (self):
- return "monName: %s\nmonID: %s\nfbmonSect: %s\nmonHoriz: %s\nmonVert: %s\n" % ( self.monName, self.monID, self.fbmonSect, self.monHoriz, self.monVert)
-
- def setSpecs(self, horiz, vert, id=None, name = None):
- self.monHoriz = horiz
- self.monVert = vert
- if id:
- self.monID = id
-
- if name:
- self.monName = name
-
- def getMonitorHorizSync(self, useProbed=0):
- if useProbed:
- return self.orig_monHoriz
- else:
- return self.monHoriz
-
- def getMonitorVertSync(self, useProbed=0):
- if useProbed:
- return self.orig_monVert
- else:
- return self.monVert
-
- def getFBMonitorSection(self):
- return self.fbmonSect
-
- def getFBMonitorMode(self):
- return self.fbmonMode
-
- def getMonitorID(self, useProbed = 0):
- if not useProbed:
- return self.monID
- else:
- if self.orig_use_probed:
- return self.probedMonitor[0]
- else:
- return self.monID
-
- def getMonitorName(self):
- return self.monName
-
- def shortDescription(self):
- if self.monName and self.monName != "" and self.monName != "Unprobed Monitor":
- return self.monName
- else:
- return _("Unable to probe")
-
- def getDDCProbeResults(self):
- if self.orig_use_probed:
- return self.probedMonitor
- else:
- return None
-
- def reset(self):
- self.monName = self.orig_monName
- self.monID = self.orig_monID
- self.fbmonSect = self.orig_fbmonSect
- self.monHoriz = self.orig_monHoriz
- self.monVert = self.orig_monVert
-
- def __init__ (self, skipDDCProbe = 0, fbDevice = None):
-
- self.monName = None
- self.monID = "Unprobed Monitor"
-
- self.fbmonSect = ""
-
- self.monHoriz = None
- self.monVert = None
-
- self.monlist = {}
- self.monids = {}
-
- # store probed values for future reference
- self.probedMonitor = []
-
- # flag if the original monitor was probed or not
- self.orig_use_probed = 0
-
- # VESA probe for monitor/videoram, etc.
- if not skipDDCProbe:
- try:
- monitor = kudzu.probe(kudzu.CLASS_MONITOR, kudzu.BUS_DDC,
- kudzu.PROBE_ALL)
-
- monEisa = None
- monName = None
- monHoriz = None
- monVert = None
-
- if monitor:
- monEisa = monitor[0].id
-
- # only guess the timings if something is non-zero
- if (monitor[0].horizSyncMin != 0 or
- monitor[0].horizSyncMax != 0 or
- monitor[0].vertRefreshMin != 0 or
- monitor[0].vertRefreshMax != 0):
- monHoriz = "%d-%d" % (monitor[0].horizSyncMin,
- monitor[0].horizSyncMax)
- monVert = "%d-%d" % (monitor[0].vertRefreshMin,
- monitor[0].vertRefreshMax)
-
- if monitor[0].desc != None:
- monName = monitor[0].desc
-
- if monVert != None and monHoriz != None and monitor[0].desc != None:
- self.probedMonitor = (monEisa, monName, monHoriz, monVert)
- self.setSpecs(monHoriz, monVert, id="DDCPROBED", name=monName)
- self.orig_use_probed = 1
- else:
- log("ddcprobe returned bogus values: %s" % (monitor,))
-
- except:
- log("ddcprobe failed")
- pass
-
- self.fbmonMode = {}
-#
-# we're removing framebuffer code
-#
-# if fbDevice != None:
-# try:
-# (vidram, depth, mode, monitor) = isys.fbconProbe("/dev/" + fbDevice)
-# self.fbmonSect = monitor
-# self.fbmonMode = {}
-# if int(depth) == 24:
-# depth = 32
-
-# self.fbmonMode[str(depth)] = [str(mode)]
-# except:
-# pass
-
- # save for reset() method
- self.orig_monName = self.monName
- self.orig_monID = self.monID
-
- self.orig_fbmonSect = self.fbmonSect
-
- self.orig_monHoriz = self.monHoriz
- self.orig_monVert = self.monVert
diff --git a/mouse.py b/mouse.py
deleted file mode 100644
index 1707553ac..000000000
--- a/mouse.py
+++ /dev/null
@@ -1,315 +0,0 @@
-#
-# mouse.py: mouse configuration data
-#
-# Copyright 1999-2002 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-import kudzu
-from simpleconfig import SimpleConfigFile
-import os
-from rhpl.translate import _, N_
-
-class Mouse (SimpleConfigFile):
- mice = {
- # (gpm protocol, X protocol, device, emulate3, shortname)
- N_("ALPS - GlidePoint (PS/2)"):
- ("ps/2", "GlidePointPS/2", "psaux", 1, "alpsps/2"),
- N_("ASCII - MieMouse (serial)"):
- ("ms3", "IntelliMouse", "ttyS", 0, "ascii"),
- N_("ASCII - MieMouse (PS/2)"):
- ("ps/2", "NetMousePS/2", "psaux", 1, "asciips/2"),
- N_("ATI - Bus Mouse"):
- ("Busmouse", "BusMouse", "atibm", 1, "atibm"),
- N_("Generic - 2 Button Mouse (serial)"):
- ("Microsoft", "Microsoft", "ttyS", 1, "generic"),
- N_("Generic - 3 Button Mouse (serial)"):
- ("Microsoft", "Microsoft", "ttyS", 0, "generic3"),
- N_("Generic - 2 Button Mouse (PS/2)"):
- ("ps/2", "PS/2", "psaux", 1, "genericps/2"),
- N_("Generic - 3 Button Mouse (PS/2)"):
- ("ps/2", "PS/2", "psaux", 0, "generic3ps/2"),
- N_("Generic - 2 Button Mouse (USB)"):
- ("imps2", "IMPS/2", "input/mice", 1, "genericusb"),
- N_("Generic - 3 Button Mouse (USB)"):
- ("imps2", "IMPS/2", "input/mice", 0, "generic3usb"),
- N_("Genius - NetMouse (serial)"):
- ("ms3", "IntelliMouse", "ttyS", 1, "geniusnm"),
- N_("Genius - NetMouse (PS/2)"):
- ("netmouse", "NetMousePS/2", "psaux", 1, "geniusnmps/2"),
- N_("Genius - NetMouse Pro (PS/2)"):
- ("netmouse", "NetMousePS/2", "psaux", 1, "geniusprops/2"),
- N_("Genius - NetScroll (PS/2)"):
- ("netmouse", "NetScrollPS/2", "psaux", 1, "geniusscrollps/2"),
- N_("Genius - NetScroll+ (PS/2)") :
- ("netmouse", "NetMousePS/2", "psaux", 1, "geniusscrollps/2+"),
- N_("Kensington - Thinking Mouse (serial)"):
- ("Microsoft", "ThinkingMouse", "ttyS", 1, "thinking"),
- N_("Kensington - Thinking Mouse (PS/2)"):
- ("ps/2", "ThinkingMousePS/2", "psaux", 1, "thinkingps/2"),
- N_("Logitech - C7 Mouse (serial, old C7 type)"):
- ("Logitech", "Logitech", "ttyS", 0, "logitech"),
- N_("Logitech - CC Series (serial)"):
- ("logim", "MouseMan", "ttyS", 0, "logitechcc"),
- N_("Logitech - Bus Mouse"):
- ("Busmouse", "BusMouse", "logibm", 0, "logibm"),
- N_("Logitech - MouseMan/FirstMouse (serial)"):
- ("MouseMan", "MouseMan", "ttyS", 0, "logimman"),
- N_("Logitech - MouseMan/FirstMouse (PS/2)"):
- ("ps/2", "PS/2", "psaux", 0, "logimmanps/2"),
- N_("Logitech - MouseMan+/FirstMouse+ (serial)"):
- ("pnp", "IntelliMouse", "ttyS", 0, "logimman+"),
- N_("Logitech - MouseMan+/FirstMouse+ (PS/2)"):
- ("ps/2", "MouseManPlusPS/2", "psaux", 0, "logimman+ps/2"),
- N_("Logitech - MouseMan Wheel (USB)"):
- ("ps/2", "IMPS/2", "input/mice", 0, "logimmusb"),
- N_("Microsoft - Compatible Mouse (serial)"):
- ("Microsoft", "Microsoft", "ttyS", 1, "microsoft"),
- N_("Microsoft - Rev 2.1A or higher (serial)"):
- ("pnp", "Auto", "ttyS", 1, "msnew"),
- N_("Microsoft - IntelliMouse (serial)"):
- ("ms3", "IntelliMouse", "ttyS", 0, "msintelli"),
- N_("Microsoft - IntelliMouse (PS/2)"):
- ("imps2", "IMPS/2", "psaux", 0, "msintellips/2"),
-
- N_("Microsoft - IntelliMouse (USB)"):
- ("ps/2", "IMPS/2", "input/mice", 0, "msintelliusb"),
-
- N_("Microsoft - Bus Mouse"):
- ("Busmouse", "BusMouse", "inportbm", 1, "msbm"),
- N_("Mouse Systems - Mouse (serial)"):
- ("MouseSystems", "MouseSystems", "ttyS", 1, "mousesystems"),
- N_("MM - Series (serial)"):
- ("MMSeries", "MMSeries", "ttyS", 1, "mmseries"),
- N_("MM - HitTablet (serial)"):
- ("MMHitTab", "MMHittab", "ttyS", 1, "mmhittab"),
- "None - None" :
- ("none", "none", None, 0, "none"),
- N_("Sun - Mouse"): ("sun", "sun", "sunmouse", 0, "sun"),
- }
-
-
- def mouseToMouse(self):
- types = {}
- for mouse in self.mice.keys():
- mouseType = self.mice[mouse][4]
- types[mouseType] = mouse
- return types
-
-
- # XXX fixme - externalize
- def __init__ (self, skipProbe = 0):
- self.info = {}
- self.device = None
- self.emulate = 0
- self.set ("Generic - 3 Button Mouse (PS/2)")
- self.wasProbed = 0
- if not skipProbe:
- self.probe()
-
- self.orig_mouse = self.get()
-
- def get_Orig(self):
- return self.orig_mouse
-
- def probed(self):
- return self.wasProbed
-
- def probe (self, frob = 0):
-
- list = kudzu.probe(kudzu.CLASS_MOUSE, kudzu.BUS_UNSPEC,
- kudzu.PROBE_ONE)
-
- if (list):
- (device, module, desc) = list[0]
-
- if frob and device == 'psaux':
- # jumpstart some ps/2 mice. Blame the kernel
- try:
- f = open ('/dev/psaux')
- f.write ('1')
- f.close()
- except:
- pass
-
- if device == "sunmouse":
- self.set("Sun - Mouse", 0)
- elif device == "psaux":
- self.set("Generic - 3 Button Mouse (PS/2)", 0)
- elif device == "input/mice":
- if module == "generic3usb" or module == "mousedev":
- self.set("Generic - 3 Button Mouse (USB)", 0)
- elif module == "genericusb":
- self.set("Generic - 2 Button Mouse (USB)", 1)
- else:
- self.set("Generic - 2 Button Mouse (serial)", 1)
-
- self.device = device
- self.wasProbed = 1
- return 1
- else:
- self.set("None - None")
- self.wasProbed = 0
- return 0
-
- def available (self):
- return self.mice
-
- def get (self):
- return (self.info ["FULLNAME"], self.emulate)
-
- def __str__(self):
- if (self.emulate):
- self.info["XEMU3"] = "yes"
- else:
- self.info["XEMU3"] = "no"
- return SimpleConfigFile.__str__(self)
-
- def makeLink(self, root):
- try:
- os.unlink(root + "/dev/mouse")
- except:
- pass
- if (self.device):
- os.symlink(self.device, root + "/dev/mouse")
-
- def getDevice(self):
- return self.device
-
- def shortDescription(self):
- if self.info.has_key("FULLNAME"):
- return self.info["FULLNAME"]
- else:
- return _("Unable to probe")
-
- def setDevice(self, device):
- self.device = device
-
- def set (self, mouse, emulateThreeButtons = -1, thedev = None):
- (gpm, x11, dev, em, shortname) = self.mice[mouse]
- self.info["MOUSETYPE"] = gpm
- self.info["XMOUSETYPE"] = x11
- self.info["FULLNAME"] = mouse
- if emulateThreeButtons != -1:
- self.emulate = emulateThreeButtons
- else:
- self.emu = em
- if thedev:
- self.device = thedev
- if not self.device:
- self.device = dev
-
- def setXProtocol (self):
- import xmouse
- try:
- curmouse = xmouse.get()
- except RuntimeError:
- # ignore errors when switching mice
- return None
- curmouse[0] = "/dev/" + self.device
- # XXX
- # IntelliMouse requires a full mouse reinit - X does not
- # handle this properly from the mouse extention at this time
- # so leave it alone
- if (not self.info["XMOUSETYPE"] == "IMPS/2"
- and not self.info["XMOUSETYPE"] == "IntelliMouse"
- and not self.info["XMOUSETYPE"] == "NetMousePS/2"
- and not self.info["XMOUSETYPE"] == "None"
- and not self.info["XMOUSETYPE"] == "none"):
- curmouse[1] = self.info["XMOUSETYPE"]
-
- curmouse[6] = self.emulate
- try:
- apply (xmouse.set, curmouse)
- except RuntimeError:
- pass
- except TypeError:
- pass
-
- def write(self, instPath):
- if self.info["FULLNAME"] == "None - None":
- return
- f = open(instPath + "/etc/sysconfig/mouse", "w")
- f.write(str (self))
- f.close()
- self.makeLink(instPath)
-
-
- def writeKS(self, f):
- f.write("mouse")
-
- for arg in self.getArgList():
- f.write(" " + arg)
- f.write("\n")
-
-
- def getArgList(self):
- args = []
-
- if self.info["FULLNAME"]:
- mouseName = self.info["FULLNAME"]
- args.append(self.mice[mouseName][4])
- if self.device:
- args.append("--device %s" %(self.device))
- if self.emulate:
- args.append("--emulthree")
-
- return args
-
-
-# maybe doesnt belong here - just ask user what mouse they have on
-# startup if kudzu didn't find one
-def mouseWindow(mouse):
- from snack import ButtonChoiceWindow, SnackScreen
- from mouse_text import MouseWindow, MouseDeviceWindow
- from constants_text import INSTALL_BACK, INSTALL_OK
- import string
- screen = SnackScreen()
-
- STEP_MESSAGE = 0
- STEP_TYPE = 1
- STEP_DEVICE = 2
- STEP_DONE = 3
- step = 0
- while step < STEP_DONE:
- if step == STEP_MESSAGE:
- button = ButtonChoiceWindow(screen, _("Mouse Not Detected"),
- _("Your mouse was not automatically "
- "detected. To proceed in the graphical "
- "installation mode, please proceed to "
- "the next screen and provide your mouse "
- "information. You may also use text mode "
- "installation which does not require a mouse."),
- buttons = [ _("OK"), _("Use text mode") ])
- if button == string.lower (_("Use text mode")):
- screen.finish ()
- return 0
- else:
- step = STEP_TYPE
- continue
-
- if step == STEP_TYPE:
- rc = MouseWindow()(screen, mouse)
- if rc == INSTALL_BACK:
- step = STEP_MESSAGE
- continue
- else:
- step = STEP_DEVICE
- continue
-
- if step == STEP_DEVICE:
- rc = MouseDeviceWindow()(screen, mouse)
- if rc == INSTALL_BACK:
- step = STEP_TYPE
- continue
- else:
- step = STEP_DONE
- continue
- screen.finish()
- return 1
diff --git a/network.py b/network.py
index 1a9a73a78..db3405799 100644
--- a/network.py
+++ b/network.py
@@ -16,7 +16,6 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-from simpleconfig import SimpleConfigFile
import string
import isys
import socket
@@ -24,6 +23,7 @@ import os
from rhpl.log import log
from rhpl.translate import _, N_
+from rhpl.simpleconfig import SimpleConfigFile
def inStrRange(v, s):
if string.find(s, v) == -1:
diff --git a/simpleconfig.py b/simpleconfig.py
deleted file mode 100644
index 0df75b6e5..000000000
--- a/simpleconfig.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# simpleconifg.py - representation of a simple configuration file (sh-like)
-#
-# Matt Wilson <msw@redhat.com>
-#
-# Copyright 1999-2001 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-import string
-
-class SimpleConfigFile:
- def __str__ (self):
- s = ""
- keys = self.info.keys ()
- keys.sort ()
- for key in keys:
- # FIXME - use proper escaping
- if type (self.info[key]) == type(""):
- s = s + key + "=\"" + self.info[key] + "\"\n"
- return s
-
- def __init__ (self):
- self.info = {}
-
- def set (self, *args):
- for (key, data) in args:
- self.info[string.upper (key)] = data
-
- def unset (self, *keys):
- for key in keys:
- key = string.upper (key)
- if self.info.has_key (key):
- del self.info[key]
-
- def get (self, key):
- key = string.upper (key)
- if self.info.has_key (key):
- return self.info[key]
- else:
- return ""
-
-
diff --git a/textw/xconfig_text.py b/textw/xconfig_text.py
index aec4b07c4..8bd9f7112 100644
--- a/textw/xconfig_text.py
+++ b/textw/xconfig_text.py
@@ -12,11 +12,12 @@
#
import copy
-from monitor import isValidSyncRange
-from videocard import Videocard_blacklist
from constants_text import *
from snack import *
+
from rhpl.translate import _
+from rhpl.monitor import isValidSyncRange
+from rhpl.videocard import Videocard_blacklist
ddc_monitor_string = _("DDC Probed Monitor")
unprobed_monitor_string = _("Unprobed Monitor")
diff --git a/videocard.py b/videocard.py
deleted file mode 100644
index 735ad87d9..000000000
--- a/videocard.py
+++ /dev/null
@@ -1,579 +0,0 @@
-#
-# videocard.py - Install data and probing for video cards
-#
-# Matt Wilson <msw@redhat.com>
-# Brent Fox <bfox@redhat.com>
-# Mike Fulbright <msf@redhat.com>
-#
-# Copyright 2001-2002 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-import copy
-import string
-import kudzu
-import os
-
-from rhpl.log import log
-from rhpl.translate import _
-
-Videocard_blacklist = ["Generic VGA compatible",
- "Generic VGA16",
- "Generic Mono",
- "Generic FBDev"]
-
-Video_cardslist = {}
-
-USE_XFREE86_V4_FB = 0
-
-def Video_cardsDBLookup(thecard):
- card = Video_cardslist[thecard]
-
- return card
-
-class VideoCard:
-#
-# This class represents the base data about a videocard. These are
-# the internal members - PLEASE use methods to access values!
-#
-# device - if framebuffer running on card this is entry in /dev (string)
-# descr - human readable description (string)
-# server - X server to use (string)
-# probedcard - value returned for kudzu containing 'Card:........'
-# cardManf - name of manufacturer (string)
-# vidRam - amount of video ram (in kB) (string)
-# cardData - record from X card database, contains a dictionary of
-# key/values.
-# devID - ID from ddcprobe (string)
-# fbmodes - if framebuffer running, video mode in use (string)
-# fbbpp - if framebuffer running, pixel depth in use (string)
-#
-# These values will be None if undefined or not applicable.
-#
-
- def __str__ (self):
- return "device: %s\ndescr : %s\nserver: %s\ncardManf: %s\nvidRam: %s\ncarddata: %s\ndevID: %s\nfbmodes: %s\nfbbpp: %s\n" % (self.device, self.descr, self.server, self.cardManf, self.vidRam, self.cardData, self.devID, self.fbmodes, self.fbbpp)
-
-
- def __init__ (self):
- self.device = None
- self.probedcard = None
- self.descr = None
- self.server = None
- self.cardManf = None
- self.vidRam = None
- self.cardData = None
- self.devID = None
- self.fbmodes = None
- self.fbbpp = None
-
- def setDevice(self, device):
- self.device = device
-
- def setDescription(self, descr):
- self.descr = descr
-
- def setProbedCard(self, card):
- self.probedcard = card
-
- def setXServer(self, server):
- self.server = server
-
- def setVideoRam(self, vidRam):
- self.vidRam = vidRam
-
- def setCardData(self, card):
- self.cardData = card
-
- def setDevID(self, devid):
- self.devID = devid
-
- def setCardManf(self, manf):
- self.cardManf = manf
-
- def setFBModes(self, fbmodes):
- self.fbmodes = fbmodes
-
- def setFBBpp(self, bpp):
- self.fbbpp = bpp
-
- def getProbedCard(self):
- return self.probedcard
-
- def getVideoRam(self):
- return self.vidRam
-
- def getDescription(self):
- return self.descr
-
- def getDevice(self):
- return self.device
-
- def getDevID(self):
- return self.devID
-
- def getXServer(self):
- return self.server
-
- def getFBBpp(self):
- return self.fbbpp
-
- def isFrameBuffer(self):
- return 0
-
- def shortDescription(self):
- if self.devID and self.devID != "":
- return self.devID
- else:
- return _("Unable to probe")
-
- # dontResolve = 1 tells us to not follow 'SEE' records to find
- # true card definition
- def getCardData(self, dontResolve = 0):
- if dontResolve:
- return self.cardData
- else:
- if self.cardData:
- return Video_cardsDBLookup(self.cardData["NAME"])
- else:
- return None
-
- def canTestSafely(self):
- cardData = self.getCardData()
- if not cardData:
- return 1
- if cardData.has_key("DRIVER"):
- curdriver = cardData["DRIVER"]
- noprobedriverList = ("i810", "tdfx")
- for adriver in noprobedriverList:
- if curdriver == adriver:
- return 0
-
- return 1
-
- def hasFixedMode(self):
- return 0
-
-
-# fake card entry for frame buffer
-class FrameBufferCard(VideoCard):
- def getCardData(self, dontResolve = 0):
- # fake entry for a frame buffer (not in cards db)
- card = {}
-
-# This makes it use the XFree86 4.x fbdev
- if USE_XFREE86_V4_FB:
- card["DRIVER"] = "fbdev"
- else:
- card["SERVER"] = "FBDev"
-
- card["NAME"] = "VGA VESA Framebuffer"
-
- return card
-
- def getXServer(self):
-
- if USE_XFREE86_V4_FB:
- return "XFree86"
- else:
- return "XF86_FBDev"
-
- def isFrameBuffer(self):
- return 1
-
- def hasFixedMode(self):
- return 1
-
-#
-# we're removing frame buffer code
-#
-# def FixedMode(self):
-# fb = isys.fbinfo()
-# if fb:
-# (x, y, bpp) = fb
-# rc = {}
-# rc[str(bpp)] = ["%sx%s" % (x, y)]
-# return rc
-# return None
-
-# fake card entry for frame buffer
-class VGA16Card(VideoCard):
- def getCardData(self, dontResolve = 0):
- # fake entry for a frame buffer (not in cards db)
- card = {}
- card["DRIVER"] = "vga"
- card["NAME"] = "Generic VGA"
-
- return card
-
- def getXServer(self):
- return "XFree86"
-
- def hasFixedMode(self):
- return 1
-
- def FixedMode(self):
- return { "4" : ["640x480"]}
-
-def VESADriverCard(vram=None):
- try:
- card = 'VESA driver (generic)'
- vc = VideoCard()
- if vram:
- vc.setVideoRam(vram)
- info = Video_cardslist[card]
- vc.setProbedCard(card)
- vc.setDevice(None)
- vc.setDescription(card)
- vc.setCardData(info)
- vc.setDevID(info["NAME"])
- vc.setXServer('XFree86')
- except:
- vc = None
-
- return vc
-
-class VideoCardInfo:
-
-#
-# This class represents the video cards on the system.
-#
-# Currently we only care about the primary card on the system.
-# This can be found by using the VideoCardInfo::primaryCard() function.
-#
-# NOTE - X configuration is not represented here. This class is
-# intended only to reprsent the available hardware on the system
-#
-
-
- def primaryCard(self, useProbed = 0):
- if useProbed:
- if self.orig_videocards and self.orig_primary < len(self.orig_videocards):
- return self.orig_videocards[self.orig_primary]
- else:
- return None
- else:
- if self.videocards and self.primary < len(self.videocards):
- return self.videocards[self.primary]
- else:
- return None
-
- def possible_ram_sizes(self):
- #--Valid video ram sizes--
- return [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]
-
- def index_closest_ram_size(self, detected):
- possram = self.possible_ram_sizes()
- match = -1
-
- for i in range(0, len(possram)-1):
- if detected <= possram[i]:
- match = i
- break
- elif detected >= possram[i]-64 and detected < possram[i+1]-65:
- match = i
- break
-
- if match < 0:
- match = len(possram)-1
-
- return match
-
- def possible_depths(self):
- #--Valid bit depths--
- return ["8", "16", "24", "32"]
-
- # returns list of modes we know card can do
- # returns None if no restrictions
- def getSupportedModes(self):
- vc = self.primaryCard()
- if not vc:
- return None
-
- carddata = vc.getCardData()
- if carddata.has_key('DRIVER') and carddata['DRIVER'] == 'vesa':
- return ['640x480', '800x600', '1024x768']
- else:
- return None
-
- return None
-
- def manufacturerDB(self):
- return ["3DLabs",
- "ABit", "AOpen", "ASUS", "ATI", "Actix", "Ark Logic", "Avance Logic",
- "Compaq", "Canopus", "Cardex", "Chaintech",
- "Chips & Technologies", "Cirrus", "Creative Labs",
- "DFI", "DSV", "DataExpert", "Dell", "Diamond", "Digital",
- "ELSA", "EONtronics", "Epson", "ExpertColor",
- "Gainward", "Genoa", "Guillemot",
- "Hercules",
- "Intel",
- "Jaton",
- "LeadTek",
- "MELCO", "MachSpeed", "Matrox", "Miro",
- "NVIDIA", "NeoMagic", "Number Nine",
- "Oak", "Octek", "Orchid",
- "Paradise", "PixelView",
- "Quantum",
- "RIVA", "Real3D", "Rendition",
- "S3", "Sharp", "SNI", "SPEA", "STB", "SiS",
- "Sierra", "Sigma", "Silicon Motion", "Soyo", "Spider", "Sun",
- "TechWorks", "Toshiba", "Trident",
- "VideoLogic", "ViewTop", "Voodoo",
- "WD", "Weitek", "WinFast"]
-
- def readCardsDB (self):
- # all the straight servers
- # uncomment if you're meaning to support XFree86 3.x servers
- # will probably require hacking elsewhere to make sure the
- # appropriate X Server package is in selected package list
-# for server in [ "3DLabs", "8514", "FBDev", "I128",
-# "Mach8", "Mach32", "Mach64", "Mono",
-# "P9000", "S3", "S3V", "SVGA", "W32", "VGA16" ]:
-# Video_cardslist["Generic " + server] = { "SERVER" : server,
-# "NAME" : "Generic " + server }
-
- if not os.access('/usr/X11R6/lib/X11/Cards', os.R_OK):
- return -1
-
- db = open ('/usr/X11R6/lib/X11/Cards')
- lines = db.readlines ()
- db.close ()
- card = {}
- name = None
- for line in lines:
- line = string.strip (line)
- if not line and name:
-# if card.has_key("DRIVER") and card.has_key("UNSUPPORTED"):
-# print "WARNING: CardsDB entry for %s says XFree86 4.x is unsupported!" % name
-
- if card.has_key("SERVER") and not card.has_key("DRIVER"):
-# print "WARNING: CardsDB entry for %s is XFree86 3.x only, dropping" % name
- pass
- else:
- Video_cardslist[name] = card
- card = {}
- name = None
- continue
-
- if line and line[0] == '#':
- continue
-
- if len (line) > 4 and line[0:4] == 'NAME':
- name = line[5:]
-
- if len (line) > 3 and line[0:3] == 'SEE':
- info = string.splitfields (line, ' ')
- seecard = string.joinfields(info[1:], ' ')
- try:
- refcard = Video_cardslist[seecard]
- except:
- continue
-
- for k in ["CHIPSET", "SERVER", "RAMDAC", "CLOCKCHIP",
- "DACSPEED", "DRIVER", "UNSUPPORTED", "NOCLOCKPROBE"]:
- if not card.has_key(k) and refcard.has_key(k):
- card[k] = refcard[k]
-
- if refcard.has_key("LINE"):
- if not card.has_key("LINE"):
- card["LINE"] = refcard["LINE"]
- else:
- card["LINE"] = card["LINE"] + "\n" + refcard["LINE"]
-
- info = string.splitfields (line, ' ')
- if card.has_key (info[0]):
- card[info[0]] = card[info[0]] + '\n' + (string.joinfields (info[1:], ' '))
- else:
- card[info[0]] = string.joinfields (info[1:], ' ')
-
- return 0
-
- def cardsDB(self):
- return Video_cardslist
-
- def __str__(self):
- retstr = "primary: %s\nvidCards: %s\n" % (self.primary, self.videocards)
- if self.primaryCard():
- retstr = retstr + ("Primary Video Card Info:\n%s" % (str(self.primaryCard())))
- return retstr
-
- def reset(self):
- self.videocards = copy.deepcopy(self.orig_videocards)
- self.primary = self.orig_primary
-
- def __init__ (self, skipDDCProbe = 0):
-
- cards = kudzu.probe (kudzu.CLASS_VIDEO,
- kudzu.BUS_PCI | kudzu.BUS_SBUS,
- kudzu.PROBE_ALL);
-
- if not skipDDCProbe:
- prval = kudzu.probe(kudzu.CLASS_VIDEO, kudzu.BUS_DDC,
- kudzu.PROBE_ALL)
- else:
- prval = None
-
- self.ddcprobe_data = prval
-
- # just use first video card we recognize
- # store as a list of class VideoCard
- self.videocards = []
- self.primary = None
-
- if self.readCardsDB() < 0:
- return None
-
- for card in cards:
- (device, server, descr) = card
-
- info = None
-
- if len (server) > 9 and server[0:10] == "Server:Sun" and descr[0:4] == "Sun|":
- server = "Card:Sun " + descr[4:]
- if len (server) > 5 and server[0:5] == "Card:":
- if server[5:] in Video_cardslist.keys():
- info = Video_cardslist [server[5:]]
- else:
- info = None
- if len (server) > 7 and server[0:7] == "Server:":
- info = { "NAME" : "Generic " + server[7:],
- "SERVER" : server[7:] }
-
- if info:
- vc = VideoCard()
- vc.setProbedCard(server)
- vc.setDevice(device)
- vc.setDescription(descr)
- vc.setCardData (info)
- vc.setDevID (info["NAME"])
-
-#
-# We are now not supporting XFree86 3.x at all, so we will take the
-# XFree86 4.x driver and complain if its unsupported
-#
- if vc.getCardData().has_key("DRIVER"):
- server = "XFree86"
- if vc.getCardData().has_key("UNSUPPORTED"):
- log("Using CardsDB entry for %s even tho its "
- "marked unsupported" % info["NAME"])
- else:
- server = None
-
- if server:
- vc.setXServer(server)
- self.videocards.append(vc)
-
- if len(self.videocards) == 0:
- # insert a best guess at a card
- if prval and prval[0].videoram > 0:
- try:
- card = 'VESA driver (generic)'
- vc = VideoCard()
- vc.setVideoRam(prval[0].videoram)
- info = Video_cardslist[card]
- vc.setProbedCard(card)
- vc.setDevice(None)
- vc.setDescription(card)
- vc.setCardData(info)
- vc.setDevID(info["NAME"])
- vc.setXServer('XFree86')
- except:
- vc = None
- else:
- vc = None
-
- if not vc:
- vc = VideoCard()
- vc.setDescription(_("Unknown Card"))
-
- self.videocards.append(vc)
- self.orig_videocards = copy.deepcopy(self.videocards)
- self.primary = 0
- self.orig_primary = self.primary
- return
-
-
- # default primary card to be the first card found
- self.primary = 0
-
- # VESA probe for videoram, etc.
- # for now assume fb corresponds to primary video card
- if prval:
- # XXX need to get vendor data from kudzu and use this code
-# if prval[0].vendor != None:
-# cardManf = prval[0].vendor
-# self.primaryCard().setCardManf(cardManf)
-# self.primaryCard().getCardData()["VENDOR"] = cardManf
-
- if prval[0].mem != 0:
- self.primaryCard().setVideoRam("%d" % (prval[0].mem,))
-
-#
-# we're removing framebuffer support
-#
- # try to get frame buffer information if we don't know video ram
-# if not self.primaryCard().getVideoRam() and self.primaryCard().getDevice():
-# try:
-# (vidram, depth, mode, monitor) = isys.fbconProbe("/dev/" + self.primaryCard().getDevice())
-# if vidram:
-# self.primaryCard().setVideoRam("%d" % vidram)
-#
-# if depth:
-# self.primaryCard().setFBModes({ "%d" % depth : [ mode ] })
-# self.primaryCard().setFBBpp( "%d" % depth )
-# except:
-# pass
-#
-# try:
-# if isys.fbinfo() != None:
-# x, y, depth = isys.fbinfo()
-# self.primaryCard().setFBBpp(depth)
-# except:
-# pass
-
- # kludge to handle i810 displays which require at least 16 Meg
- if (self.primaryCard().getCardData()).has_key("DRIVER"):
- cardData = self.primaryCard().getCardData()
- if cardData["DRIVER"] == "i810":
- self.primaryCard().setVideoRam("16384")
-
-
- # save so we can reset
- self.orig_videocards = copy.deepcopy(self.videocards)
- self.orig_primary = self.primary
-
-
-#
-# XXX needed for kickstart only (via installclass.py::configureX())
-# some useful routines for setting videocard in various ways
-# needs to be ported to new VideoCard object
-
- # pass videocard object for desired card; this sets card to be
- # primary card
- def setVidcard (self, videocard):
- self.primary = self.videocards.index(videocard)
-
-
- # find the appropriate videocard object for the requested card name
- # this will only find the first instance of any card
- def locateVidcardByName (self, card):
- for vc in self.videocards:
- print vc.getDescription()
- if (vc.getDescription() == card):
- return vc
- raise RuntimeError, "Could not find valid video card driver"
-
- # find the appropriate videocard object for the requested server name
- # this will only find the first instance of any card
- def locateVidcardByServer (self, server):
- for vc in self.videocards:
- if (vc.getXServer() == server):
- return vc
- raise RuntimeError, "Could not find valid video card driver."
diff --git a/xf86config.py b/xf86config.py
index d3c23c352..2ddc5f00d 100644
--- a/xf86config.py
+++ b/xf86config.py
@@ -26,10 +26,10 @@ import isys
import time
import os
from kbd import Keyboard
-from mouse import Mouse
-from rhpl.translate import _
from rhpl.log import log
+from rhpl.mouse import Mouse
+from rhpl.translate import _
XF86Config_template = """
# File generated by anaconda.
diff --git a/xserver.py b/xserver.py
index f0558791d..bfa3b3fc4 100644
--- a/xserver.py
+++ b/xserver.py
@@ -22,12 +22,13 @@ import sys
import time
from xf86config import *
from kbd import Keyboard
-from mouse import Mouse
from snack import *
-from rhpl.translate import _
from constants_text import *
from mouse_text import MouseWindow, MouseDeviceWindow
-from videocard import VGA16Card, VESADriverCard
+
+from rhpl.translate import _
+from rhpl.mouse import Mouse
+from rhpl.videocard import VGA16Card, VESADriverCard
serverPath = ""