Compare commits
3 Commits
b3f79020f4
...
b985ea7a92
Author | SHA1 | Date | |
---|---|---|---|
b985ea7a92 | |||
452a6097e3 | |||
1893e7c201 |
@ -194,8 +194,16 @@ class IDFMAPI:
|
|||||||
def get_line_weather(self, res, disruptions, mode, line):
|
def get_line_weather(self, res, disruptions, mode, line):
|
||||||
for l in res["lines"]:
|
for l in res["lines"]:
|
||||||
if l["id"] == "line:IDFM:" + IDFMAPI.lines[mode][line]:
|
if l["id"] == "line:IDFM:" + IDFMAPI.lines[mode][line]:
|
||||||
|
disruptionIds = []
|
||||||
|
disruptionTypes = {}
|
||||||
for impactedObject in l["impactedObjects"]:
|
for impactedObject in l["impactedObjects"]:
|
||||||
for disruptionId in impactedObject["disruptionIds"]:
|
for disruptionId in impactedObject["disruptionIds"]:
|
||||||
|
if disruptionId not in disruptionIds:
|
||||||
|
disruptionTypes[disruptionId] = impactedObject["type"]
|
||||||
|
disruptionIds.append(disruptionId)
|
||||||
|
|
||||||
|
for disruptionId in disruptionIds:
|
||||||
|
impactType = disruptionTypes[disruptionId]
|
||||||
status = "past"
|
status = "past"
|
||||||
for ap in disruptions[disruptionId]["applicationPeriods"]:
|
for ap in disruptions[disruptionId]["applicationPeriods"]:
|
||||||
end = datetime.strptime(ap["end"], "%Y%m%dT%H%M%S")
|
end = datetime.strptime(ap["end"], "%Y%m%dT%H%M%S")
|
||||||
@ -209,7 +217,12 @@ class IDFMAPI:
|
|||||||
|
|
||||||
status = "active"
|
status = "active"
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if "cause" in disruptions and disruptions["cause"] == "INFORMATION":
|
||||||
|
continue
|
||||||
|
|
||||||
disruptions[disruptionId]["status"] = status
|
disruptions[disruptionId]["status"] = status
|
||||||
|
disruptions[disruptionId]["scope"] = impactType
|
||||||
yield disruptions[disruptionId]
|
yield disruptions[disruptionId]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -217,12 +230,17 @@ class IDFMAPI:
|
|||||||
def get_line_icon(config, mode, line, size, fill="gray", state=""):
|
def get_line_icon(config, mode, line, size, fill="gray", state=""):
|
||||||
if mode == "M" or mode == "metros":
|
if mode == "M" or mode == "metros":
|
||||||
icon_mode = "metro"
|
icon_mode = "metro"
|
||||||
|
mode = "metros"
|
||||||
line = line.replace("B", "bis")
|
line = line.replace("B", "bis")
|
||||||
elif mode == "T" or mode == "tramways":
|
elif mode == "T" or mode == "tramways":
|
||||||
icon_mode = "tram"
|
icon_mode = "tram"
|
||||||
|
mode = "tramways"
|
||||||
line = line.replace("T", "").lower()
|
line = line.replace("T", "").lower()
|
||||||
elif mode == "R" or mode == "rers":
|
elif mode == "R" or mode == "rers":
|
||||||
icon_mode = "RER"
|
icon_mode = "RER"
|
||||||
|
mode = "rers"
|
||||||
|
elif mode == "B":
|
||||||
|
mode = "buses"
|
||||||
|
|
||||||
img_line = None
|
img_line = None
|
||||||
if mode == "rers" and fill != "white":
|
if mode == "rers" and fill != "white":
|
||||||
@ -415,15 +433,20 @@ class RATPWeatherModule:
|
|||||||
|
|
||||||
state = ""
|
state = ""
|
||||||
fill = "darkgray"
|
fill = "darkgray"
|
||||||
if "NO_SERVICE" in states:
|
if disruption["scope"] == "line" and ("NO_SERVICE" in states or "BLOQUANTE" in states):
|
||||||
fill = "black"
|
fill = "black"
|
||||||
state = "_trafic_grand"
|
state = "_trafic_grand"
|
||||||
elif "REDUCED_SERVICE" in states or "UNKNOWN_EFFECT" in states or "OTHER_EFFECT" in states:
|
elif "PERTURBEE" in states:
|
||||||
|
fill = "brown"
|
||||||
|
state = "_trafic_moyen"
|
||||||
|
elif "REDUCED_SERVICE" in states or "UNKNOWN_EFFECT" in states or "OTHER_EFFECT" in states or "NO_SERVICE" in states or "BLOQUANTE" in states:
|
||||||
fill = "teal"
|
fill = "teal"
|
||||||
state = "_trafic_moyen"
|
state = "_trafic_moyen"
|
||||||
elif "BLOQUANTE TRAVAUX" in states:
|
elif "BLOQUANTE TRAVAUX" in states:
|
||||||
fill = "teal"
|
fill = "teal"
|
||||||
state = "_travaux_moyen"
|
state = "_travaux_moyen"
|
||||||
|
elif "INFORMATION" in states:
|
||||||
|
state = "_travaux_petit"
|
||||||
elif len(states) > 0:
|
elif len(states) > 0:
|
||||||
fill = "gray"
|
fill = "gray"
|
||||||
state = "_trafic_petit"
|
state = "_trafic_petit"
|
||||||
@ -518,6 +541,8 @@ class RATPNextStopModule:
|
|||||||
})
|
})
|
||||||
|
|
||||||
align -= int(line_height * 0.33)
|
align -= int(line_height * 0.33)
|
||||||
|
if align < 0:
|
||||||
|
align = 0
|
||||||
image = image.crop((0,0,width, min(align, height)))
|
image = image.crop((0,0,width, min(align, height)))
|
||||||
|
|
||||||
return image, alerts
|
return image, alerts
|
||||||
|
@ -147,8 +147,10 @@ class WeatherJumboCurrentModule:
|
|||||||
|
|
||||||
dayweather = list(itertools.islice(WeatherAPI().get_hourly(), 2))
|
dayweather = list(itertools.islice(WeatherAPI().get_hourly(), 2))
|
||||||
|
|
||||||
if dayweather[0]["weather"][0]["description"] != dayweather[1]["weather"][0]["description"]:
|
if dayweather[0]["weather"][0]["description"] != curweather["weather"][0]["description"]:
|
||||||
display_longtext(draw, (width*self.middle_align, height/1.28), dayweather[1]["weather"][0]["description"] + " la prochaine heure.\n" + thisdayweather["summary"] + ".", fill="black", anchor="lm", font=fnt_Rig, maxwidth=(1-self.middle_align)*width)
|
description = dayweather[0]["weather"][0]["description"]
|
||||||
|
description = description[0].upper() + description[1:]
|
||||||
|
display_longtext(draw, (width*self.middle_align, height/1.28), description + " la prochaine heure.\n" + thisdayweather["summary"] + ".", fill="black", anchor="lm", font=fnt_Rig, maxwidth=(1-self.middle_align)*width)
|
||||||
else:
|
else:
|
||||||
display_longtext(draw, (width*self.middle_align, height/1.28), thisdayweather["summary"] + ".", fill="black", anchor="lm", font=fnt_Rig, maxwidth=(1-self.middle_align)*width)
|
display_longtext(draw, (width*self.middle_align, height/1.28), thisdayweather["summary"] + ".", fill="black", anchor="lm", font=fnt_Rig, maxwidth=(1-self.middle_align)*width)
|
||||||
|
|
||||||
@ -361,30 +363,38 @@ class WeatherAlerts:
|
|||||||
|
|
||||||
def gen_alerts(self):
|
def gen_alerts(self):
|
||||||
alerts = []
|
alerts = []
|
||||||
|
lastStartTime = 0
|
||||||
|
lastEndTime = 0
|
||||||
|
|
||||||
for alert in WeatherAPI().get_alerts():
|
for alert in WeatherAPI().get_alerts():
|
||||||
if alert["severity"] == "Moderate":
|
icon = "weather/wi-gale-warning.png"
|
||||||
icon = "weather/wi-small-craft-advisory.png"
|
startTime = WeatherAPI().read_timestamp(alert["start"])
|
||||||
elif alert["severity"] != "Moderate":
|
endTime = WeatherAPI().read_timestamp(alert["end"]-1)
|
||||||
icon = "weather/wi-gale-warning.png"
|
vendTime = WeatherAPI().read_timestamp(alert["end"])
|
||||||
else:
|
|
||||||
icon = None
|
|
||||||
|
|
||||||
startTime = WeatherAPI().read_timestamp(alert["effective"])
|
|
||||||
endTime = WeatherAPI().read_timestamp(alert["expires"])
|
|
||||||
# Show alert timing if under a day
|
# Show alert timing if under a day
|
||||||
if startTime.hour != endTime.hour:
|
if startTime.hour != vendTime.hour:
|
||||||
subtitle = startTime.strftime(("%x " if startTime.day != datetime.now().day else "") + "%X") + " - " + endTime.strftime(("%x " if startTime.day != endTime.day else "") + "%X")
|
subtitle = startTime.strftime(("%x " if startTime.day != datetime.now().day else "") + "%X") + " - " + endTime.strftime(("%x " if startTime.day != endTime.day else "") + "%X")
|
||||||
elif startTime.day != datetime.now().day:
|
elif startTime.day != datetime.now().day:
|
||||||
subtitle = startTime.strftime("%x")
|
subtitle = startTime.strftime("%x")
|
||||||
else:
|
else:
|
||||||
subtitle = ""
|
subtitle = ""
|
||||||
|
|
||||||
|
if len(alerts) >= 1 and alerts[len(alerts)-1]["title"] == alert["event"]:
|
||||||
|
startTime = lastStartTime
|
||||||
|
if startTime.hour != vendTime.hour:
|
||||||
|
alerts[len(alerts)-1]["subtitle"] = startTime.strftime(("%x " if startTime.day != datetime.now().day else "") + "%X") + " - " + endTime.strftime(("%x " if startTime.day != endTime.day else "") + "%X")
|
||||||
|
elif startTime.day != datetime.now().day:
|
||||||
|
alerts[len(alerts)-1]["subtitle"] = startTime.strftime("%x")
|
||||||
|
continue
|
||||||
|
lastStartTime = startTime
|
||||||
|
lastEndTime = vendTime
|
||||||
|
|
||||||
alerts.append({
|
alerts.append({
|
||||||
"icon": icon,
|
"icon": icon,
|
||||||
"title": alert["headline"],
|
"title": alert["event"],
|
||||||
"subtitle": subtitle,
|
"subtitle": subtitle,
|
||||||
"description": alert["desc"],
|
"description": alert["description"],
|
||||||
})
|
})
|
||||||
|
|
||||||
return alerts
|
return alerts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user