def start_simulation(params): numberOfSteps = int(params["numberOfSteps"]) simulation.start(numberOfSteps) ts = simulation.find_ts(do_update=False) agents = agent.agents(ts,ts); #logs = simulation.logs_for_ts(params["numberOfSteps"]) return WebSuccess(data = agents )
def wrapper(*args, **kwds): web_result = {} try: web_result = f(*args, **kwds) if type(web_result) is not WebSuccess: web_result = WebSuccess( message="Action performed successfully", data=web_result) except WebException as error: web_result = WebError(_get_message(error), error.data) except InternalException as error: message = _get_message(error) if type(error) == SevereInternalException: core.logger.critical(traceback.format_exc()) web_result = WebError( "There was a critical internal error. Contact an administrator." ) else: core.logger.error(traceback.format_exc()) web_result = WebError(message) except Exception as error: core.logger.error(traceback.format_exc()) return Response(json.dumps(web_result), content_type='appication/json')
def last_messages(): return WebSuccess(data= simulation.last_messages(1000))
def delete_all(): agent.deleteAll() simulation.clear_all_messages() simulation.reset_ts() agents = agent.agents(0,0) return WebSuccess(data = agents);
def agents(params): ts_real = simulation.find_ts(do_update=False) ts_requested = params.get("ts") data = agent.agents(ts_real,ts_requested); return WebSuccess(data = data);
def upload_agent(): f = request.files['file'] agent.upload_agent(f) return WebSuccess();
def new_agent(params): ts = simulation.find_ts(do_update=False) data = agent.new_agent(ts,params) return WebSuccess(data = data)