summaryrefslogtreecommitdiffstats
path: root/monitor.py
diff options
context:
space:
mode:
authorMike Fulbright <msf@redhat.com>2001-06-20 16:28:33 +0000
committerMike Fulbright <msf@redhat.com>2001-06-20 16:28:33 +0000
commitcff0656999d6c122e851182fe8e7479e46252427 (patch)
treedddb9edad81d4a47121e7a3ca4399396787d66d3 /monitor.py
parentcb87bc2094b906919c748856b6b52fde4ee0e98b (diff)
downloadanaconda-cff0656999d6c122e851182fe8e7479e46252427.tar.gz
anaconda-cff0656999d6c122e851182fe8e7479e46252427.tar.xz
anaconda-cff0656999d6c122e851182fe8e7479e46252427.zip
these turn out to be important
Diffstat (limited to 'monitor.py')
-rw-r--r--monitor.py204
1 files changed, 204 insertions, 0 deletions
diff --git a/monitor.py b/monitor.py
new file mode 100644
index 000000000..a812147be
--- /dev/null
+++ b/monitor.py
@@ -0,0 +1,204 @@
+import string
+import kudzu
+import iutil
+import isys
+from translate import _
+from log import log
+
+
+
+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/X11R6/share/Xconfigurator/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, ';')
+ 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 lookupMonitor(self, monID):
+ if not self.monlist:
+ self.readMonitorsDB()
+
+ for man in self.monlist.keys():
+ for model in self.monlist[man]:
+ if monID == model[0]:
+ return model
+
+ return 0
+
+ def __str__ (self):
+ return "monEisa: %s\nmonName: %s\nmonID: %s\nfbmonSect: %s\nmonHoriz: %s\nmonVert: %s\n" % ( self.monEisa, 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 getMonitorID(self, useProbed = 0):
+ if not useProbed:
+ return self.monID
+ else:
+ return self.orig_monID
+
+ def shortDescription(self):
+ if self.monName and self.monName != "" and self.monName != "Unprobed Monitor":
+ return self.monName
+ else:
+ return _("Unable to probe")
+
+
+ def reset(self):
+ self.monEisa = self.orig_monEisa
+ 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):
+
+ self.monEisa = None
+ self.monName = None
+ self.monID = "Unprobed Monitor"
+
+ self.fbmonSect = ""
+
+ self.monHoriz = None
+ self.monVert = None
+
+ self.monlist = {}
+ self.monids = {}
+
+ # VESA probe for monitor/videoram, etc.
+ if not skipDDCProbe:
+ try:
+ probe = string.split (iutil.execWithCapture ("/usr/sbin/ddcprobe", ['ddcprobe']), '\n')
+ for line in probe:
+ if line and line[:8] == "EISA ID:":
+ self.monEisa = string.lower(line[9:])
+ self.monID = line[9:]
+
+ if line and line[:6] == "\tName:":
+ if not self.monName or len (self.monName) < len (line[7:]):
+ self.monName = line[7:]
+
+ if line and line[:15] == "\tTiming ranges:":
+ ranges = string.split (line, ',')
+ self.monHoriz = string.strip (string.split (ranges[0], '=')[1])
+ self.monVert = string.strip (string.split (ranges[1], '=')[1])
+ if self.monEisa:
+ # read the monitor DB
+ self.readMonitorsDB()
+ if self.monids.has_key (self.monEisa):
+ (man, model, eisa, vert, horiz) = self.monids[self.monEisa]
+ self.setSpecs(horiz, vert, id=model, name=model)
+ except:
+ log("ddcprobe failed")
+ pass
+
+ try:
+# (vidram, depth, mode, monitor) = isys.fbconProbe("/dev/" + self.device)
+# self.fbmonSect = monitor
+ log("ERROR - trying to run fbconProbe w/o knowing fb device!!")
+
+ except:
+ pass
+
+ # save for reset() method
+ self.orig_monEisa = self.monEisa
+ 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