def update(self): debug = False while True: location_data = api.get_bus_locations() # XXX For debugging. Replay data for when there isn't any. if debug or not location_data: for locations in api.replay_period(): for client in self.clients: gevent.spawn(self.send, client, json.dumps(locations)) if not debug or location_data: for client in self.clients: gevent.spawn(self.send, client, json.dumps(location_data)) s3.save_list('locations.{0}'.format(time.strftime('%Y%m%dT%H%M%S')), location_data) api.set_last_locations(location_data) time.sleep(60)
def get_bus_locations(): return json.dumps(api.get_bus_locations())