Debian Codegraph @

tests/sample_process.py

raw symbols SCIP
1 #! /usr/bin/env python3
2
3 # tests on CmdTask will use this script as an external process.
4 # - If you call this script with 3 or more arguments, the process returns
5 # exit code (166).
6 # - If you call this script with arguments "please fail", it returns exit
7 # code (11).
8 # - If you call this script with arguments "check env", it verifies the
9 # existence of an environment variable called "GELKIPWDUZLOVSXE", with
10 # value "1". If the variable is not found, the process returns exit code (99).
11 # - Otherwise, any first argument gets written to STDOUT. Any second argument
12 # gets written to STDERR.
13
14 import os
15 import sys
16
17 if __name__ == "__main__":
18 # error
19 if len(sys.argv) > 3:
20 sys.exit(166)
21 # fail
22 if len(sys.argv) == 3 and sys.argv[1]=='please' and sys.argv[2]=='fail':
23 sys.stdout.write("out ouch")
24 sys.stderr.write("err output on failure")
25 sys.exit(11)
26 # check env
27 if len(sys.argv) == 3 and sys.argv[1]=='check' and sys.argv[2]=='env':
28 if os.environ.get('GELKIPWDUZLOVSXE') == '1':
29 sys.exit(0)
30 else:
31 sys.exit(99)
32 # ok
33 if len(sys.argv) > 1:
34 sys.stdout.write(sys.argv[1])
35 if len(sys.argv) > 2:
36 sys.stderr.write(sys.argv[2])
37 sys.exit(0)