示例#1
0
    def refresh(self, wtype: str = ""):
        if wtype in self.core.wtypes:
            data = self.core.refresh(wtype)['history_entry']
            output = helpers.output_data(data)
        else:
            output = helpers.output_error('Please specify a correct wtype')

        return output
示例#2
0
    def history_entries_all(self, wtype: str="", source={}, location={}):
        if wtype not in WTYPES:
            return helpers.output_error('Please specify correct forecast type')

        search_string = {}

        if source:
            source = helpers.db_find(self.sources()['source'], {'name': request.query.source})[0]
            search_string['source'] = source

        if location:
            location = helpers.db_find(self.locations()['location'], {'name': request.query.location})[0]
            search_string['location'] = location

        history = self.core.history.entries
        try:
            data = helpers.db_find(history, {'wtype': wtype})
        except (IndexError, KeyError):
            print(history)
            data = []
        return helpers.output_data(data)