Alert on RATP failures

This commit is contained in:
nemunaire 2022-08-14 18:25:06 +02:00
commit 18ab123c3a
3 changed files with 54 additions and 25 deletions

37
main.py
View file

@ -36,7 +36,7 @@ from PIL import Image, ImageDraw, ImageFont
def main():
image = Image.new('1', (480, 800), 255)
#image = Image.new('RGB', (480, 800), 'white')
#image = Image.new('L', (480, 800), 'white')
draw = ImageDraw.Draw(image)
import modules
@ -44,48 +44,57 @@ def main():
# Weather
# Toolbar
from modules.weather import WeatherToolbarModule
image.paste(WeatherToolbarModule().draw_module(config, 480, 50), (0, 0))
# Current Weather
from modules.weather import WeatherJumboCurrentModule
image.paste(WeatherJumboCurrentModule().draw_module(config, 480, 150), (0, 50))
image.paste(WeatherJumboCurrentModule().draw_module(config, 480, 150), (0, 0))
# rule
image.paste(modules.RuleModule().draw_module(config, 450, 1), (30, 192))
image.paste(modules.RuleModule().draw_module(config, 450, 1), (30, 142))
# pluie
from modules.weather import WeatherRainModule
image.paste(WeatherRainModule().draw_module(config, 480-int(480/1.6), 94), (0, 205))
image.paste(WeatherRainModule().draw_module(config, 480-int(480/1.6), 94), (0, 155))
# moon phase
from modules.weather import WeatherMoonPhaseModule
moon = WeatherMoonPhaseModule().draw_module(config, 65, 65)
image.paste(moon, (0, 163), moon)
image.paste(moon, (0, 113), moon)
# weekly weather
from modules.weather import WeeklyWeatherModule
image.paste(WeeklyWeatherModule().draw_module(config, int(480/1.6), 275), (480-int(480/1.6), 305))
image.paste(WeeklyWeatherModule().draw_module(config, int(480/1.6), 275), (480-int(480/1.6), 255))
# RATP weather
from modules.ratp import RATPWeatherModule
ratp = RATPWeatherModule().draw_module(config, int(480/1.6), 94)
image.paste(ratp, (480-int(480/1.6), 205))
image.paste(ratp, (480-int(480/1.6), 155))
# Toolbar
from modules.weather import WeatherToolbarModule
image.paste(WeatherToolbarModule().draw_module(config, 480, 50), (0, 530))
# alerts
alerts = []
from modules.weather import WeatherAlerts
alerts += [a for a in RATPWeatherModule().gen_alerts()]
alerts += WeatherAlerts().gen_alerts()
from modules import AlertsModule
mod = AlertsModule(alerts).draw_module(config, 480, 200)
image.paste(mod, (0, 580-mod.height-5), mod)
mod = AlertsModule(alerts).draw_module(config, 480, 330)
if mod.height > 260:
image.paste(mod, (0, 580-mod.height+67), mod)
elif mod.height < 100:
image.paste(mod, (0, 580-mod.height-40), mod)
else:
image.paste(mod, (0, 580-mod.height-5), mod)
# températures
from modules.weather import WeatherTemperatureModule
image.paste(WeatherTemperatureModule().draw_module(config, 480, 200), (0, 580))
if mod.height > 260:
image.paste(WeatherTemperatureModule().draw_module(config, 480, 200 - mod.height+260), (0, 580 + mod.height-260))
else:
image.paste(WeatherTemperatureModule().draw_module(config, 480, 200), (0, 580))
# sunrise/set
from modules.weather import WeatherSunModule