[#308] Removed weather
backend.
This commit is contained in:
parent
b8a4b9e4c5
commit
bc8730d6f0
3 changed files with 0 additions and 70 deletions
|
@ -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:
|
|
@ -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:
|
|
@ -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
|
Loading…
Reference in a new issue