示例#1
0
文件: app.py 项目: akosel/a2bus
    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)
示例#2
0
文件: app.py 项目: akosel/a2bus
def get_bus_locations():
    return json.dumps(api.get_bus_locations())