Menu

[r39]: / drPDB.py  Maximize  Restore  History

Download this file

33 lines (23 with data), 820 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import bdb
import sys
class drPdb(bdb.Bdb):
""" Subclass of bdb that sends output to the prompt window """
def __init__(self, drFrame):
""" Set up for debugging """
bdb.Bdb.__init__(self)
self.save_stdout = sys.stdout
self.save_stderr = sys.stderr
self.lineno = None
self.stack = []
self.curindex = 0
self.curframe = None
self.drFrame = drFrame
def start(self,debugfile,globals=None,locals=None):
""" Start debugging """
# redirect output to prompt window
#sys.stdout = sys.stderr = self.drFrame.txtPrompt
cmd = 'execfile("' + debugfile + '")'
self.run(cmd,globals,locals)
# get output back to original
sys.stdout = self.save_stdout
sys.stderr = self.save_stderr