Esempio n. 1
0
def pack_station_for_list_views(wban, months):

    station = Station.get(Station.WBAN == wban)
    station_data = {'wban': station.WBAN}
    station_data['name'] = station.attributes.get('Name', 'n/a')
    station_data['state'] = station.attributes.get('State', 'n/a')
    station_data['station_data'] = months

    return station_data
Esempio n. 2
0
    def get(self):
        station_name = self.request.get("station")
        genre = self.request.get("genre")

        station = Station.get(station_name)

        self.response.headers[b"Content-Type"] = b"application/json; charset=utf-8"
        data = json.dumps(station.to_dict(genre), ensure_ascii=False)
        self.response.write(data)
Esempio n. 3
0
    def on_get(self, req, resp, name=None):
        try:
            if not name:
                result = list(Station.select().dicts())
            else:
                result = model_to_dict(Station.get(name=name))
        except Exception as ex:
            self.logger.error(ex)
            print ex
            description = ('Aliens have attacked our base! We will '
                           'be back as soon as we fight them off. '
                           'We appreciate your patience.')

            raise falcon.HTTPServiceUnavailable('Service Outage', description,
                                                30)

        resp.context['result'] = result
        resp.status = falcon.HTTP_200