Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 1 | """twit - The Window-Independent Tracer. |
| 2 | |
| 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 |
| 8 | |
| 9 | main program: nothing but a bit of glue to put it all together. |
| 10 | |
| 11 | Jack Jansen, CWI, August 1996.""" |
| 12 | |
| 13 | import os |
Jack Jansen | d859785 | 1996-11-11 15:40:45 +0000 | [diff] [blame] | 14 | import sys |
| 15 | |
| 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) |
| 20 | |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 21 | if os.name == 'mac': |
Jack Jansen | 92ca16c | 1996-10-23 15:38:26 +0000 | [diff] [blame] | 22 | import MacOS |
Jack Jansen | b280e2b | 1996-12-23 17:11:00 +0000 | [diff] [blame] | 23 | MacOS.splash(502) # Try to show the splash screen |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 24 | import mactwit_app; twit_app = mactwit_app |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 25 | else: |
| 26 | try: |
| 27 | import _tkinter |
| 28 | have_tk = 1 |
| 29 | except ImportError: |
| 30 | have_tk = 0 |
| 31 | if have_tk: |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 32 | import tktwit_app; twit_app = tktwit_app |
| 33 | else: |
Jack Jansen | a1560cf | 1996-09-26 16:26:05 +0000 | [diff] [blame] | 34 | print 'Please implementent machine-dependent code and try again:-)' |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 35 | sys.exit(1) |
| 36 | |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 37 | import sys |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 38 | |
| 39 | def main(): |
| 40 | twit_app.Initialize() |
Jack Jansen | 92ca16c | 1996-10-23 15:38:26 +0000 | [diff] [blame] | 41 | if os.name == 'mac': |
| 42 | MacOS.splash() |
Jack Jansen | a1560cf | 1996-09-26 16:26:05 +0000 | [diff] [blame] | 43 | twit_app.Twit('none', None) |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 44 | |
| 45 | def run(statement, globals=None, locals=None): |
| 46 | twit_app.Initialize() |
Jack Jansen | a1560cf | 1996-09-26 16:26:05 +0000 | [diff] [blame] | 47 | twit_app.Twit('run', (statement, globals, locals)) |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 48 | |
| 49 | def post_mortem(t): |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 50 | Initialize() |
Jack Jansen | a1560cf | 1996-09-26 16:26:05 +0000 | [diff] [blame] | 51 | twit_app.Twit('pm', t) |
Jack Jansen | 4892ab7 | 1996-09-24 15:35:50 +0000 | [diff] [blame] | 52 | |
| 53 | def pm(): |
| 54 | post_mortem(sys.last_traceback) |
| 55 | |
| 56 | if __name__ == '__main__': |
| 57 | main() |
| 58 | |
| 59 | |