X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=inline;f=stevens_renderer.py;h=bf97785256933beb350d84d9ee47b87a59ca8ec2;hb=2b7583ad79a2adb41b08a1086a9a780da83b776c;hp=0916aee9fd694b1a6a1b84e0bb251c6d459b8111;hpb=86f7e14f34b43ed8eb8cf5eaf113a4ecca976327;p=kiosk.git
diff --git a/stevens_renderer.py b/stevens_renderer.py
index 0916aee..bf97785 100644
--- a/stevens_renderer.py
+++ b/stevens_renderer.py
@@ -1,12 +1,10 @@
#!/usr/bin/env python3
-import datetime
import json
import logging
import requests
from typing import Dict
-import datetime_utils
import file_writer
import renderer
@@ -24,31 +22,48 @@ class stevens_renderer(renderer.abstaining_renderer):
ret = f'''
- temperature: |
- {conditions['temperature']}°{conditions['temperatureUnit'][0]} |
+ Temp: |
+ {conditions['temperature']}°{conditions['temperatureUnit'][0]} |
- weather: |
- {conditions['weather']} |
+ Weather: |
+ {conditions['weather']} |
- road: |
- {conditions['roadCondition']} |
+ Roadway: |
+ {conditions['roadCondition']} |
'''
- if 'restrictionOne' in conditions or 'restrictionTwo' in conditions:
+ if 'restrictionOne' in conditions and 'restrictionTwo' in conditions:
ret += '''
- restrictions: |
- '''
- if 'restrictionOne' in conditions:
+ | Restrictions: |
+ '''
+ count = 0
+ msg = conditions['restrictionOne'].get('publicPage', 'no restrictions')
+ if msg.lower() != 'no restrictions':
+ count += 1
+ msg = conditions['restrictionTwo'].get('publicPage', 'no restrictions')
+ if msg.lower() != 'no restrictions':
+ count += 1
+ if count == 2:
ret += f'''
- {conditions['restrictionOne']['travelDirectionName']}:
- {conditions['restrictionOne']['publicPage']} '''
- if 'restrictionTwo' in conditions:
- ret += f'''
- {conditions['restrictionTwo']['travelDirectionName']}:
- {conditions['restrictionTwo']['publicPage']}'''
- ret += ' |
'
+ {conditions['restrictionOne']['travelDirectionName']}:
+ {conditions['restrictionOne']['publicPage']}
+ {conditions['restrictionTwo']['travelDirectionName']}:
+ {conditions['restrictionTwo']['publicPage']}'''
+ elif count == 1:
+ msg = conditions['restrictionOne'].get('publicPage', 'no restrictions')
+ if msg.lower() != 'no restrictions':
+ ret += f'''
+ {conditions['restrictionOne']['travelDirectionName']}:
+ {conditions['restrictionOne']['publicPage']}
'''
+ else:
+ ret += f'''
+ {conditions['restrictionTwo']['travelDirectionName']}:
+ {conditions['restrictionTwo']['publicPage']}
'''
+ else:
+ ret += '''None.
'''
+ ret += ''
return ret
def render_forecast(forecasts: Dict[str, str]) -> str:
@@ -60,7 +75,7 @@ class stevens_renderer(renderer.abstaining_renderer):
color = ' BGCOLOR="#dfefff"'
ret += f'''
- {f['periodText']} |
+ {f['periodText']} |
{f['forecastText']} |
'''
ret += ''
@@ -71,9 +86,11 @@ class stevens_renderer(renderer.abstaining_renderer):
if camera['cameraId'] == 8063:
return f'''
-
+
+
+
- {camera['cameraLabel']} ({camera['direction']})
+ {camera['cameraLabel']} ({camera['direction']})
'''
return ''
@@ -85,14 +102,9 @@ class stevens_renderer(renderer.abstaining_renderer):
conditions = contents['condition']
cameras = contents['cameras']
forecasts = contents['stationForecasts'][0]
- now = datetime_utils.now_pacific()
- tss = conditions['displayDate']
- tss = tss.replace('Z', '+00:00')
- ts = datetime.datetime.strptime(tss, '%Y-%m-%dT%H:%M:%S.%f%z')
- tss = datetime_utils.describe_timedelta_briefly(now - ts)
with file_writer.file_writer('stevens-conditions_5_3000.html') as f:
f.write(f'''
-Stevens Pass Conditions ~{tss} ago:
+Stevens Pass Conditions:
@@ -112,5 +124,6 @@ class stevens_renderer(renderer.abstaining_renderer):
return True
return False
-test = stevens_renderer({"Test", 123})
-test.periodic_render("Test")
+# Test:
+#test = stevens_renderer({"Test", 123})
+#test.periodic_render("Test")