def get(self): '''Write out the JSON for the user's saved stops.''' current_user = users.get_current_user() if current_user: user = models.User.all().filter('user ='******'position') else: return else: stops = default_user.stops() stopList = [] for index, stop in enumerate(stops): try: stop_data = functions.apiwrapperfor(stop.agency_tag).get_stop_data(stop) stopList.append({"id": stop.key().id() if stop.is_saved() else index, "title": stop.title, "lat" : float(stop_data['lat']) if stop_data['lat'] else None, "lon" : float(stop_data['lon']) if stop_data['lon'] else None, "agencyTag": stop.agency_tag, "lineTag": stop.line_tag, "directionTag": stop.direction_tag, "stopTag": stop.stop_tag, "destinationTag": stop.destination_tag, "timeToStop": stop.time_to_stop, "position": stop.position, "isEditable": True if stop.is_saved() else False, }) except: stopList.append({"error" : True}) self.response.out.write(json.dumps(stopList))
def get(self, t): '''Write out vehicles.''' current_user = users.get_current_user() if current_user: stops = models.User.all().filter('user ='******'position') else: stops = default_user.stops() lineDict = {} for stop in stops: if (stop.agency_tag + " " + stop.line_tag) in lineDict.keys(): continue else: lineDict[(stop.agency_tag + " " + stop.line_tag)] = functions.apiwrapperfor(stop.agency_tag).get_vehicle_data(stop, t) self.response.out.write(json.dumps(lineDict.values()))
def get(self): '''Write out the JSON predictions for the user's stops.''' current_user = users.get_current_user() if current_user: user = models.User.all().filter('user ='******'position') else: return else: user = default_user.user() stops = default_user.stops() predictionList = [] for index, stop in enumerate(stops): predictionList.append({ "id": stop.key().id() if stop.is_saved() else index, "directions": functions.apiwrapperfor(stop.agency_tag).get_directions(stop, user.max_arrivals, user.show_missed) }) self.response.out.write(json.dumps(predictionList))