source: SHX/trunk/sandbox/shimport.py @ 116

Revision 116, 1.2 KB checked in by marcus, 11 years ago (diff)
  • refactoring for use as later python module
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Rev Id Date
Line 
1#! /usr/bin/env python
2
3import os
4import sys
5import ctypes
6
7class sh(object):
8    """wrapper class for seismic handler shared library"""
9   
10    def __init__(self):
11        """load and init shared lib via ctypes interface"""
12       
13        # get seismic handler installation root
14        try:
15            root = os.environ["SH_ROOT"]
16        except KeyError:
17            print >> sys.stderr, "SH environment variable not found"
18            sys.exit()
19           
20        # load shared lib
21        try:
22            sh = ctypes.cdll.LoadLibrary(os.path.join(root, "libshc.so"))
23        except Exception, e:
24            print >> sys.stderr, "error loading shared lib", e
25            sys.exit()
26           
27        # keep reference to lib
28        self.sh = sh
29       
30        # list holding used commands
31        self.cmd = {}
32       
33        self.main()
34#        sh.main()
35#        i = ctypes.c_int.in_dll(sh, "tc")
36#        print i
37#        i.value = 2
38#        print ctypes.c_int.in_dll(sh, "tc")
39           
40    def main(self):
41        """replacement for sh's main loop"""
42        pass
43       
44#        c = __import__("y.t", globals(), locals(), ["y"]).a
45
46if __name__ == "__main__":
47    a = sh() 
Note: See TracBrowser for help on using the repository browser.