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