Created
March 7, 2017 06:01
-
-
Save yohm/3123a58b0f05fa9b84c05bbf71d47fc6 to your computer and use it in GitHub Desktop.
wrapper_sample.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, json, subprocess | |
# Load JSON file | |
fp = open( '_input.json' ) | |
params = json.load( fp ) | |
# Prepare input file | |
f = open('configuration.xml', 'w') | |
param_txt = """<configuration> | |
<input> | |
<length value="%d" /> | |
<velocity value="%f"/> | |
<time value="%d"/> | |
<seed value="%d"/> | |
</input> | |
</configuration> | |
""" % (params['length'], params['velocity'], params['time'], params['_seed']) | |
f.write(param_txt) | |
f.flush() | |
# Execution of the simulator | |
simulator = os.path.abspath(os.path.dirname(__file__)) + "/my_simulator.out" | |
cmd = [simulator, '-c', 'configuration.xml'] | |
sys.stderr.write("Running: %s\n" % cmd) | |
subprocess.check_call(cmd) | |
sys.stderr.write("Successfully finished\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment