summaryrefslogtreecommitdiffstats
path: root/contrib/python/bindings/test-state-pass.py
blob: 56aba97c428650ed0ac3e6aeb57e1d8d5b37bafd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
import os.path


def main(argv):
    if not os.path.isfile(argv[1]):
        sys.exit(os.EX_NOINPUT)
    
    # where to find uscxmlNativePython.py?
    if os.path.exists('../../../build/cli/lib'):
        sys.path.append('../../../build/cli/lib')
    if os.environ.get('USCXML_PYTHON_PATH') and os.path.exists(os.environ['USCXML_PYTHON_PATH']):
        sys.path.append(os.environ['USCXML_PYTHON_PATH'])    
    
    import uscxmlNativePython as uscxml
    
    print "Processing" + argv[1]

    interpreter = uscxml.Interpreter.fromURL(argv[1]);
    state = interpreter.step()
    while state != uscxml.USCXML_FINISHED:
        state = interpreter.step()
    
    if interpreter.isInState("pass"):
        sys.exit(os.EX_OK)
        
    sys.exit(os.EX_OSERR)

if __name__ == "__main__":
    main(sys.argv)