+#!/usr/bin/python
-import bdb
-import os, sys, signal, types
-from cPickle import Pickler
-from string import joinfields
+import os
+import signal
+import string
+import sys
import traceback
+import types
-import gettext
-_ = lambda x: gettext.ldgettext("pomona", x)
-
-import logging
-log = logging.getLogger("pomona")
+from cPickle import Pickler
dumpHash = {}
-def dumpClass(instance, fd, level=0, parentkey="", skipList=[]):
+def dumpClass(instance, fd, level=0, parentkey=""):
# protect from loops
try:
if not dumpHash.has_key(instance):
return
if (instance.__class__.__dict__.has_key("__str__") or
- instance.__class__.__dict__.has_key("__repr__")):
+ instance.__class__.__dict__.has_key("__repr__")):
fd.write("%s\n" % (instance,))
return
- fd.write("%s instance, containing members:\n" %
- (instance.__class__.__name__))
+
+ fd.write("%s instance, containing members:\n" % (instance.__class__.__name__))
pad = ' ' * ((level) * 2)
for key, value in instance.__dict__.items():
else:
curkey = key
- # Don't dump objects that are in our skip list, though ones that are
- # None are probably okay.
- if eval("instance.%s is not None" % key) and \
- eval("id(instance.%s)" % key) in skipList:
- continue
-
if type(value) == types.ListType:
fd.write("%s%s: [" % (pad, curkey))
first = 1
else:
first = 0
if type(item) == types.InstanceType:
- dumpClass(item, fd, level + 1, skipList=skipList)
+ dumpClass(item, fd, level + 1,)
else:
fd.write("%s" % (item,))
fd.write("]\n")
+
elif type(value) == types.DictType:
fd.write("%s%s: {" % (pad, curkey))
first = 1
else:
fd.write("%s: " % (k,))
if type(v) == types.InstanceType:
- dumpClass(v, fd, level + 1, parentkey = curkey, skipList=skipList)
+ dumpClass(v, fd, level + 1, parentkey = curkey)
else:
fd.write("%s" % (v,))
fd.write("}\n")
+
elif type(value) == types.InstanceType:
fd.write("%s%s: " % (pad, curkey))
- dumpClass(value, fd, level + 1, parentkey=curkey, skipList=skipList)
+ dumpClass(value, fd, level + 1, parentkey=curkey)
+
else:
fd.write("%s%s: %s\n" % (pad, curkey, value))
-def dumpException(out, text, tb, pomona):
- skipList = []
- idSkipList = []
-
- # Catch attributes that do not exist at the time we do the exception dump
- # and ignore them.
- for k in skipList:
- try:
- eval("idSkipList.append(id(%s))" % k)
- except:
- pass
-
+def dumpException(out, text, tb, installer):
p = Pickler(out)
out.write(text)
try:
out.write("\n\n")
- dumpClass(pomona, out, skipList=idSkipList)
+ dumpClass(installer, out)
except:
out.write("\nException occurred during state dump:\n")
traceback.print_exc(None, out)
lst.extend(traceback.format_exception_only(type, value))
return lst
-def handleException(pomona, (type, value, tb)):
- if isinstance(value, bdb.BdbQuit):
- sys.exit(1)
-
+def handleException(installer, (type, value, tb)):
# restore original exception handler
sys.excepthook = sys.__excepthook__
+ installer.log.error("Exception occured. Read more in /tmp/instdump.txt.")
+
# get traceback information
list = formatException(type, value, tb)
- text = joinfields(list, "")
+ text = string.joinfields(list, "")
- # save to local storage first
+ # save to local storage
out = open("/tmp/instdump.txt", "w")
- dumpException(out, text, tb, pomona)
+ dumpException(out, text, tb, installer)
out.close()
- win = pomona.intf.exceptionWindow(text, "/tmp/instdump.txt")
+ win = installer.intf.exceptionWindow(text, "/tmp/instdump.txt")
if not win:
- pomona.intf.__del__()
+ installer.intf.__del__()
os.kill(os.getpid(), signal.SIGKILL)
while 1:
win.run()
- rc = win.getrc()
- if rc == 0:
- pomona.intf.__del__()
+ if win.getrc() == 0:
+ installer.intf.__del__()
os.kill(os.getpid(), signal.SIGKILL)