Revision 529,
1.3 KB
checked in by marcus, 11 years ago
(diff) |
- accept tailing comment within command line
- access to trace info entries
|
-
Property svn:executable set to
*
|
Line | |
---|
1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | """ |
---|
4 | Helper script for executing SH scripts and interactive usage. |
---|
5 | """ |
---|
6 | |
---|
7 | import os |
---|
8 | import sys |
---|
9 | from StringIO import StringIO |
---|
10 | try: |
---|
11 | import readline |
---|
12 | except: |
---|
13 | # readline module is not available on Windows OS |
---|
14 | pass |
---|
15 | from SeismicHandler.modules.parse import Script, Symbol, Switches |
---|
16 | from SeismicHandler.basics.error import ShxError |
---|
17 | from SeismicHandler.config import Settings |
---|
18 | from SeismicHandler.basics.codes import LICENCE, VERSION |
---|
19 | |
---|
20 | |
---|
21 | def run(filename): |
---|
22 | path, script = os.path.split(filename) |
---|
23 | |
---|
24 | # add path information |
---|
25 | if path: |
---|
26 | s = Script(open(sys.argv[1]), Symbol(), Switches(), searchpath=[path]) |
---|
27 | else: |
---|
28 | s = Script(open(sys.argv[1]), Symbol(), Switches()) |
---|
29 | |
---|
30 | s.run() |
---|
31 | |
---|
32 | |
---|
33 | def interactive(): |
---|
34 | s = Script(StringIO(""), Symbol(), Switches()) |
---|
35 | while True: |
---|
36 | try: |
---|
37 | inp = raw_input("|shx> ") |
---|
38 | except (EOFError, KeyboardInterrupt): |
---|
39 | quit() |
---|
40 | |
---|
41 | s.feed(StringIO(inp + os.linesep)) |
---|
42 | try: |
---|
43 | s.run() |
---|
44 | except ShxError: |
---|
45 | if Settings.swSherrstop: |
---|
46 | quit(1) |
---|
47 | except NotImplementedError: |
---|
48 | print "Command currently not available!" |
---|
49 | |
---|
50 | |
---|
51 | if __name__ == "__main__": |
---|
52 | if len(sys.argv) > 1: |
---|
53 | run(sys.argv[1]) |
---|
54 | else: |
---|
55 | print LICENCE % VERSION |
---|
56 | interactive() |
---|
Note: See
TracBrowser
for help on using the repository browser.