Esempio n. 1
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)
Esempio n. 2
0
    def refresh(self, wtype: str):
        threads = []
        for entry in helpers.db_find(self.__table, {'wtype': wtype}):
            t = threading.Thread(target=(self.__refresh_thread), kwargs={'proxy': entry['proxy']})
            t.daemon = True
            threads.append(t)

        for t in threads:
            t.start()

        for t in threads:
            t.join()