def tetres_admin_api_urls(): api_urls = {} for k, v in CLIENT_APIURLs.__dict__.items(): if k.startswith('_'): continue api_urls[k] = v for k, v in ADMIN_APIURLs.__dict__.items(): if k.startswith('_'): continue api_urls[k] = v data_types = {} for k, v in ttypes.__dict__.items(): if not hasattr(v, '_info_type_') or not inspect.isclass( v) or k.startswith('_'): continue data_types[v._info_type_] = { '__module__': v.__module__, '__class__': v.__name__ } return jsonify({ 'api_urls': api_urls, 'data_types': data_types }, indent=4)
def ticas_turn_off(): def shutdown_server(): func = request.environ.get('werkzeug.server.shutdown') if func is None: raise RuntimeError('Not running with the Werkzeug Server') func() shutdown_server() return jsonify({'code': 1})
def get_infra(): infra = Infra.get_infra() corridors = [] for corr in sorted(infra.get_corridors(), key=lambda c: c.name): corridors.append(corr.__dict__) try: rnodes = _get_items(infra.rnodes) dets = _get_items(infra.detectors) dmss = _get_items(infra.dmss) cams = _get_items(infra.cameras) meters = _get_items(infra.meters) configs = {} for k in SHARED_CONFIGS: configs[k] = getattr(ticas_cfg, k) configs['ROUTE_CLASS'] = types.Route.__name__ configs['ROUTE_MODULE'] = types.Route.__module__ api_urls_info = {} for k, v in api_urls.__dict__.items(): if k.startswith('_'): continue api_urls_info[k] = v return jsonify({ 'config': configs, 'api_urls' : api_urls_info, 'corridor_list': corridors, 'rnode_list': rnodes, 'detector_list': dets, 'dms_list': dmss, 'camera_list': cams, 'meter_list': meters, }, indent=4, only_name=True ) except Exception as ex: import sys, traceback print('-' * 60) traceback.print_exc(file=sys.stdout) print('-' * 60)
def tetres_user_api_urls(): api_urls = {} for k, v in CLIENT_APIURLs.__dict__.items(): if k.startswith('_'): continue api_urls[k] = v for k, v in USER_APIURLs.__dict__.items(): if k.startswith('_'): continue api_urls[k] = v data_types = {} types = [ ttypes.TTRouteInfo, ttypes.EstimationRequestInfo, ttypes.ReliabilityEstimationModeInfo, ttypes.OperatingConditionsInfo, ttypes.WeatherConditionInfo, ttypes.IncidentConditionInfo, ttypes.WorkzoneConditionInfo, ttypes.SpecialeventConditionInfo, ttypes.SnowmanagementConditionInfo, ttypes.WeekdayConditionInfo, ttypes.OperatingConditionParamInfo, ] for v in types: k = v.__name__ if not hasattr(v, '_info_type_') or not inspect.isclass( v) or k.startswith('_'): continue data_types[v._info_type_] = { '__module__': v.__module__, '__class__': v.__name__ } return jsonify({ 'api_urls': api_urls, 'data_types': data_types }, indent=4)
def ticas_is_on(): return jsonify({'code': 1, 'msg': 'TICAS server is already running!'})
def not_found(error): return make_response(jsonify({ 'code': -1, 'error': 'Not found' }), 404)
def not_found(error): return make_response(jsonify({ 'code': -1, 'error': 'Bad request' }), 400)
def get_corridors(): infra = Infra.get_infra() return jsonify({'corridors': infra.get_corridor_names()})