def api_find_system(glob): result = [] with env.use() as data: for syst in data.find_systems_by_glob(glob, keep_data=True): if syst is not None: result.append(syst.data) if not len(result): result = None bottle.response.content_type = 'application/json' return {'result': result}
def api_system_station(system_name, station_name): with env.use() as data: stat = data.get_station(system_name, station_name, keep_data=True) if stat is not None: result = stat.data result['system'] = stat.system.data else: result = None bottle.response.content_type = 'application/json' return {'result': result}
def api_system(name): with env.use() as data: syst = data.get_system(name, keep_data=True) if syst is not None: result = syst.data else: bottle.response.status = 400 result = None bottle.response.content_type = 'application/json' return {'result': result}
def api_system_stations(name): result = [] with env.use() as data: syst = data.get_system(name, keep_data=True) if syst is not None: for stat in data.get_stations(syst, keep_station_data=True): if stat is not None: result.append(stat.data) if not len(result): result = None bottle.response.content_type = 'application/json' return {'result': result}
elif sys.argv[1] == "search2": input = sys.argv[2] syst = pgnames.get_system(input) if syst is not None: coords, relpos_confidence = syst.position, syst.uncertainty print("Est. position of {0}: {1} (+/- {2}LY)".format(input, coords, int(relpos_confidence))) else: sect = pgnames.get_sector(input) if sect is not None: print("{0} is {1}, has origin {2}".format(input, str(sect), sect.origin)) else: print("Could not find sector or system") elif sys.argv[1] == "localdatatest": env.set_verbosity(2) with env.use() as envdata: run_test(envdata.find_all_systems()) elif sys.argv[1] == "id64datatest": env.set_verbosity(2) env.start() import id64data for name, id64 in id64data.known_systems.items(): pgpos, pgunc, pgn2, pgbody = system.calculate_from_id64(id64) knownsys = system.from_name(name) if knownsys is None: # print("Unknown system: {} ({})".format(name, id64)) continue if any([abs(pgpos[i] - knownsys.position[i]) > (pgunc / 2) for i in range(3)]): print("Bad ID64: {} actually at {}, meant to be at {} +/- {}LY".format(knownsys.name, knownsys.position, pgpos, pgunc/2)) env.stop()