Clarify portability and main program.
[python/dscho.git] / Mac / Tools / twit / twit.py
blob2cc3f41218794b1c03ba4cfb0b71df196c6d5ba1
1 """twit - The Window-Independent Tracer.
3 Interface:
4 twit.main() Enter debugger in inactive interactive state
5 twit.run(stmt, globals, locals) Enter debugger and start running stmt
6 twit.post_mortem(traceback) Enter debugger in post-mortem mode on traceback
7 twit.pm() Enter debugger in pm-mode on sys.last_traceback
9 main program: nothing but a bit of glue to put it all together.
11 Jack Jansen, CWI, August 1996."""
13 import os
14 import sys
16 # Add our directory to path, if needed
17 dirname = os.path.split(__file__)[0]
18 if not dirname in sys.path:
19 sys.path.append(dirname)
21 if os.name == 'mac':
22 import MacOS
23 MacOS.splash(502) # Try to show the splash screen
24 import mactwit_app; twit_app = mactwit_app
25 else:
26 try:
27 import _tkinter
28 have_tk = 1
29 except ImportError:
30 have_tk = 0
31 if have_tk:
32 import tktwit_app; twit_app = tktwit_app
33 else:
34 print 'Please implementent machine-dependent code and try again:-)'
35 sys.exit(1)
37 import sys
39 def main():
40 twit_app.Initialize()
41 if os.name == 'mac':
42 MacOS.splash()
43 twit_app.Twit('none', None)
45 def run(statement, globals=None, locals=None):
46 twit_app.Initialize()
47 twit_app.Twit('run', (statement, globals, locals))
49 def post_mortem(t):
50 Initialize()
51 twit_app.Twit('pm', t)
53 def pm():
54 post_mortem(sys.last_traceback)
56 if __name__ == '__main__':
57 main()