Exemplo n.º 1
0
    def add_location(self, accuweather_city_name: str = '', gismeteo_city_name: str = '', country_name: str = '', longitude: str = '', gismeteo_id: str = '', iso_country: str = '', city_name: str = '', latitude: str = '', accuweather_id: str = ''):

        location = helpers.merge_dicts(LOCATION_ENTRY_SCHEMA, {'accuweather_city_name': accuweather_city_name, 'gismeteo_city_name': gismeteo_city_name, 'country_name': country_name, 'longitude': longitude, 'gismeteo_id': gismeteo_id, 'iso_country': iso_country, 'city_name': city_name, 'latitude': latitude, 'accuweather_id': accuweather_id})

        data = self.core.proxies.add_location(location, self.environment()['environment'])

        return helpers.output_data(data)
Exemplo n.º 2
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
Exemplo n.º 3
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)
Exemplo n.º 4
0
 def proxies(self):
     data = self.core.proxies.proxy_info
     return helpers.output_data(data)
Exemplo n.º 5
0
 def locations(self):
     data = self.core.settings.locations
     return helpers.output_data(data)
Exemplo n.º 6
0
 def sources(self):
     data = self.core.settings.sources_info
     return helpers.output_data(data)
Exemplo n.º 7
0
 def environment(self) -> Dict[str, Any]:
     data = self.core.settings.environment
     return helpers.output_data(data)