--- /dev/null
+#!/usr/bin/env python3
+
+import logging
+import os
+from typing import Dict, Optional, List, Tuple
+
+from pyutils.files import file_utils
+
+import kiosk_constants as constants
+import file_writer
+import globals
+import renderer
+import trigger
+
+
+logger = logging.getLogger(__file__)
+
+RECIPE_PAGE = os.path.join(constants.pages_dir, "recipe_1_82400.html")
+
+
+class RecipeTrigger(trigger.trigger):
+ def get_triggered_page_list(self) -> Optional[List[Tuple[str, int]]]:
+ if globals.get("recipe_page_triggered"):
+ logger.debug("Recipe page is triggered!")
+ return [(RECIPE_PAGE, trigger.trigger.PRIORITY_HIGH)]
+ return None
+
+
+class RecipeRenderer(renderer.abstaining_renderer):
+ def __init__(
+ self,
+ url_location: str,
+ name_to_timeout_dict: Dict[str, int],
+ ) -> None:
+ super().__init__(name_to_timeout_dict)
+ self.url_location = url_location
+
+ def periodic_render(self, key: str) -> bool:
+ triggered = False
+ if file_utils.does_path_exist(self.url_location):
+ with open(self.url_location, "r") as rf:
+ url = rf.read()
+ url.strip()
+ logger.debug(f"Read {url} from {self.url_location}, writing the page")
+
+ if url and len(url) > 0:
+ with file_writer.file_writer(RECIPE_PAGE) as f:
+ f.write('<IFRAME SRC="{url}"></IFRAME>')
+ triggered = True
+
+ if not triggered:
+ file_utils.remove(RECIPE_PAGE)
+ logger.debug("Signaling the trigger")
+ globals.put("recipe_page_triggered", triggered)
+ return True
import seattletimes_rss_renderer
import stevens_renderer
import kiosk_secrets as secrets
+import recipe_renderer_and_trigger
import stock_renderer
import twitter_renderer
import urbanist_renderer
# frequency in the renderer thread of ~once a minute. It just means that
# everytime it check these will be stale and happen.
__registry = [
-# stranger_renderer.stranger_events_renderer(
-# {"Fetch Events": (hours * 12), "Shuffle Events": (always)}
-# ),
+ # stranger_renderer.stranger_events_renderer(
+ # {"Fetch Events": (hours * 12), "Shuffle Events": (always)}
+ # ),
myq_renderer.garage_door_renderer(
{"Poll MyQ": (minutes * 5), "Update Page": (always)}
),
"Fetch News": (hours * 1),
"Shuffle News": (always),
},
- 'bellevuewa.gov',
- ['/calendar/events.xml'],
- 'Bellevue City Calendar'
+ "bellevuewa.gov",
+ ["/calendar/events.xml"],
+ "Bellevue City Calendar",
),
bellevue_reporter_rss_renderer.bellevue_reporter_rss_renderer(
{"Fetch News": (hours * 1), "Shuffle News": (always)},
"Bellevue Reporter",
),
urbanist_renderer.urbanist_renderer(
- {'Fetch News': (hours * 2), 'Shuffle News': (always)},
- 'www.theurbanist.org',
- ['/feed/'],
- 'The Urbanist',
+ {"Fetch News": (hours * 2), "Shuffle News": (always)},
+ "www.theurbanist.org",
+ ["/feed/"],
+ "The Urbanist",
),
mynorthwest_rss_renderer.mynorthwest_rss_renderer(
{"Fetch News": (hours * 1), "Shuffle News": (always)},
["/rss/RSSMarketsMain.xml", "/rss/WSJcomUSBusiness.xml"],
"WSJBusiness",
),
- stevens_renderer.stevens_renderer(
- {'Unused': (minutes * 30)}
- ),
+ stevens_renderer.stevens_renderer({"Unused": (minutes * 30)}),
google_news_rss_renderer.google_news_rss_renderer(
{"Fetch News": (minutes * 30), "Shuffle News": (always)},
"news.google.com",
"VNQ",
"VNQI",
],
- {
- "BTC-USD": "BTC",
- "GC=F": "GOLD"
- },
+ {"BTC-USD": "BTC", "GC=F": "GOLD"},
),
seattletimes_rss_renderer.seattletimes_rss_renderer(
{"Fetch News": (hours * 4), "Shuffle News": (always)},
weather_renderer.weather_renderer(
{"Fetch Weather (Stevens)": (hours * 3)}, "stevens"
),
- weather_renderer.weather_renderer(
- {"Fetch Weather (Telma)": (hours * 3)}, "telma"),
+ weather_renderer.weather_renderer({"Fetch Weather (Telma)": (hours * 3)}, "telma"),
local_photos_mirror_renderer.local_photos_mirror_renderer(
{"Index Photos": (hours * 24), "Choose Photo": (always)}
),
twitter_renderer.twitter_renderer(
{"Fetch Tweets": (minutes * 15), "Shuffle Tweets": (always)}
),
+ recipe_renderer_and_trigger.RecipeRenderer(
+ "/home/pi/.recipe_url", {"Maybe Render Recipe Page": (always)}
+ ),
]