blob: 2cc3f41218794b1c03ba4cfb0b71df196c6d5ba1 [file] [log] [blame]
Jack Jansen4892ab71996-09-24 15:35:50 +00001"""twit - The Window-Independent Tracer.
2
3Interface:
4twit.main() Enter debugger in inactive interactive state
5twit.run(stmt, globals, locals) Enter debugger and start running stmt
6twit.post_mortem(traceback) Enter debugger in post-mortem mode on traceback
7twit.pm() Enter debugger in pm-mode on sys.last_traceback
8
9main program: nothing but a bit of glue to put it all together.
10
11Jack Jansen, CWI, August 1996."""
12
13import os
Jack Jansend8597851996-11-11 15:40:45 +000014import sys
15
16# Add our directory to path, if needed
17dirname = os.path.split(__file__)[0]
18if not dirname in sys.path:
19 sys.path.append(dirname)
20
Jack Jansen4892ab71996-09-24 15:35:50 +000021if os.name == 'mac':
Jack Jansen92ca16c1996-10-23 15:38:26 +000022 import MacOS
Jack Jansenb280e2b1996-12-23 17:11:00 +000023 MacOS.splash(502) # Try to show the splash screen
Jack Jansen4892ab71996-09-24 15:35:50 +000024 import mactwit_app; twit_app = mactwit_app
Jack Jansen4892ab71996-09-24 15:35:50 +000025else:
26 try:
27 import _tkinter
28 have_tk = 1
29 except ImportError:
30 have_tk = 0
31 if have_tk:
Jack Jansen4892ab71996-09-24 15:35:50 +000032 import tktwit_app; twit_app = tktwit_app
33 else:
Jack Jansena1560cf1996-09-26 16:26:05 +000034 print 'Please implementent machine-dependent code and try again:-)'
Jack Jansen4892ab71996-09-24 15:35:50 +000035 sys.exit(1)
36
Jack Jansen4892ab71996-09-24 15:35:50 +000037import sys
Jack Jansen4892ab71996-09-24 15:35:50 +000038
39def main():
40 twit_app.Initialize()
Jack Jansen92ca16c1996-10-23 15:38:26 +000041 if os.name == 'mac':
42 MacOS.splash()
Jack Jansena1560cf1996-09-26 16:26:05 +000043 twit_app.Twit('none', None)
Jack Jansen4892ab71996-09-24 15:35:50 +000044
45def run(statement, globals=None, locals=None):
46 twit_app.Initialize()
Jack Jansena1560cf1996-09-26 16:26:05 +000047 twit_app.Twit('run', (statement, globals, locals))
Jack Jansen4892ab71996-09-24 15:35:50 +000048
49def post_mortem(t):
Jack Jansen4892ab71996-09-24 15:35:50 +000050 Initialize()
Jack Jansena1560cf1996-09-26 16:26:05 +000051 twit_app.Twit('pm', t)
Jack Jansen4892ab71996-09-24 15:35:50 +000052
53def pm():
54 post_mortem(sys.last_traceback)
55
56if __name__ == '__main__':
57 main()
58
59