RATP: get schedule can return alerts too
This commit is contained in:
parent
20916e60d1
commit
36068e9d10
3
main.py
3
main.py
@ -85,9 +85,10 @@ def main(only_on_coming_evt=False, ignore_module=[], force_coming_event=True, **
|
||||
evt_coming = force_coming_event or ical.non_local_event_coming(config) or ical.local_event_ending(config)
|
||||
if evt_coming:
|
||||
from modules.ratp import RATPNextStopModule
|
||||
nstops = RATPNextStopModule().draw_module(config, ["RB/cite+universitaire", "M7/porte+d'italie"], int(480/1.6), 275)
|
||||
nstops, nalerts = RATPNextStopModule().draw_module(config, ["RB/cite+universitaire/A", "M7/porte+d'italie/A", "B125/raspail+++jaures/A"], int(480/1.6), 275)
|
||||
image.paste(nstops, (480-int(480/1.6), 255))
|
||||
occuped_space = nstops.height
|
||||
alerts += nalerts
|
||||
elif only_on_coming_evt:
|
||||
# stop here in this case
|
||||
return
|
||||
|
@ -287,6 +287,8 @@ class RATPNextStopModule:
|
||||
image = Image.new('RGB', (width, height), '#fff')
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
alerts = []
|
||||
|
||||
fnt_R = ImageFont.truetype(IDFMAPI.fnt_R_path, line_height)
|
||||
fnt_B = ImageFont.truetype(IDFMAPI.fnt_RB_path, line_height)
|
||||
|
||||
@ -297,6 +299,7 @@ class RATPNextStopModule:
|
||||
tmp = stop.split("/", 2)
|
||||
mode = tmp[0][0]
|
||||
line = tmp[0][1:]
|
||||
try:
|
||||
if 1 < len(tmp) < 4:
|
||||
prep = {}
|
||||
for s in api.get_schedules(mode, line, *tmp[1:]):
|
||||
@ -337,7 +340,13 @@ class RATPNextStopModule:
|
||||
|
||||
align += line_height
|
||||
align += int(line_height * 0.33)
|
||||
except Exception as e:
|
||||
alerts.append({
|
||||
"title": "Impossible de récupérer les horaires du " + mode + line + " pour " + tmp[1],
|
||||
"description": type(e).__name__ + ": " + (e.message if hasattr(e, 'message') else str(e)),
|
||||
"icon": "wi-earthquake.png",
|
||||
})
|
||||
|
||||
image = image.crop((0,0,width, min(align, height)))
|
||||
|
||||
return image
|
||||
return image, alerts
|
||||
|
Loading…
x
Reference in New Issue
Block a user