From bc8730d6f0e0331edbfcf05e0df5961ad65912e1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 20 Nov 2023 01:54:10 +0100 Subject: [PATCH] [#308] Removed `weather` backend. --- platypush/backend/weather/__init__.py | 39 ------------------- .../weather/openweathermap/__init__.py | 23 ----------- .../weather/openweathermap/manifest.yaml | 8 ---- 3 files changed, 70 deletions(-) delete mode 100644 platypush/backend/weather/__init__.py delete mode 100644 platypush/backend/weather/openweathermap/__init__.py delete mode 100644 platypush/backend/weather/openweathermap/manifest.yaml diff --git a/platypush/backend/weather/__init__.py b/platypush/backend/weather/__init__.py deleted file mode 100644 index 81dbb992bb..0000000000 --- a/platypush/backend/weather/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -import time - -from platypush.backend import Backend -from platypush.context import get_plugin -from platypush.message.event.weather import NewWeatherConditionEvent - - -class WeatherBackend(Backend): - """ - Abstract class for weather update backends. - """ - - def __init__(self, plugin_name: str, poll_seconds: int, **kwargs): - """ - :param plugin_name: Name of the weather plugin to be used. - :param poll_seconds: How often the backend should check for updates, in seconds. - """ - super().__init__(**kwargs) - self.plugin_name = plugin_name - self.poll_seconds = poll_seconds - self.latest_update = {} - - def run(self): - super().run() - weather = get_plugin(self.plugin_name) - self.logger.info('Initialized {} backend'.format(self.__class__.__name__)) - - while not self.should_stop(): - current_weather = weather.get_current_weather().output - current_weather.pop('time', None) - - if current_weather != self.latest_update: - self.bus.post(NewWeatherConditionEvent(plugin_name=self.plugin_name, **current_weather)) - - self.latest_update = current_weather - time.sleep(self.poll_seconds) - - -# vim:sw=4:ts=4:et: diff --git a/platypush/backend/weather/openweathermap/__init__.py b/platypush/backend/weather/openweathermap/__init__.py deleted file mode 100644 index 26f35b1de5..0000000000 --- a/platypush/backend/weather/openweathermap/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -from platypush.backend.weather import WeatherBackend - - -class WeatherOpenweathermapBackend(WeatherBackend): - """ - Weather forecast backend that leverages the OpenWeatherMap API. - - Requires: - - * The :class:`platypush.plugins.weather.openweathermap.WeatherOpenWeatherMapPlugin` plugin configured - - """ - - def __init__(self, poll_seconds: int = 60, **kwargs): - """ - :param poll_seconds: How often the backend should check for updates (default: every minute). - """ - super().__init__( - plugin_name='weather.openweathermap', poll_seconds=poll_seconds, **kwargs - ) - - -# vim:sw=4:ts=4:et: diff --git a/platypush/backend/weather/openweathermap/manifest.yaml b/platypush/backend/weather/openweathermap/manifest.yaml deleted file mode 100644 index 70b8cc8710..0000000000 --- a/platypush/backend/weather/openweathermap/manifest.yaml +++ /dev/null @@ -1,8 +0,0 @@ -manifest: - events: - platypush.message.event.weather.NewWeatherConditionEvent: when there is a weather - condition update - install: - pip: [] - package: platypush.backend.weather.openweathermap - type: backend