Commit 68bca20f authored by Jérome Perrin's avatar Jérome Perrin

add a new script entry point to run one simulation with simulation class

This script can be used to debug a json saved from the GUI
parent 132faea4
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# along with DREAM. If not, see <http://www.gnu.org/licenses/>. # along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# =========================================================================== # ===========================================================================
import sys
import json import json
import traceback import traceback
import multiprocessing import multiprocessing
...@@ -121,11 +122,22 @@ def _runSimulation(parameter_dict, queue): ...@@ -121,11 +122,22 @@ def _runSimulation(parameter_dict, queue):
def main(*args): def main(*args):
# start the server
file_handler = logging.FileHandler(os.path.join(os.path.dirname(__file__), '..', '..', 'log', 'dream.log')) file_handler = logging.FileHandler(os.path.join(os.path.dirname(__file__), '..', '..', 'log', 'dream.log'))
file_handler.setLevel(logging.DEBUG) file_handler.setLevel(logging.DEBUG)
app.logger.addHandler(file_handler) app.logger.addHandler(file_handler)
app.run(debug=True) app.run(debug=True)
def run(*args):
# run with one topology input
args = args or sys.argv[1:]
input_data = json.load(open(args[0]))
queue = multiprocessing.Queue()
_runSimulation(input_data, queue)
output_data = queue.get()
print json.dumps(output_data, indent=True)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
...@@ -19,6 +19,7 @@ setup( ...@@ -19,6 +19,7 @@ setup(
[console_scripts] [console_scripts]
dream_platform=dream.platform:main dream_platform=dream.platform:main
dream_simulation=dream.simulation.LineGenerationJSON:main dream_simulation=dream.simulation.LineGenerationJSON:main
dream_run=dream.platform:run
"""), """),
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment