5 from typing import Dict, Optional, List, Tuple
7 from pyutils.files import file_utils
9 import kiosk_constants as constants
16 logger = logging.getLogger(__file__)
18 RECIPE_PAGE = os.path.join(constants.pages_dir, "recipe_1_82400.html")
21 class RecipeTrigger(trigger.trigger):
22 def get_triggered_page_list(self) -> Optional[List[Tuple[str, int]]]:
23 if globals.get("recipe_page_triggered"):
24 logger.debug("Recipe page is triggered!")
25 return [(RECIPE_PAGE, trigger.trigger.PRIORITY_HIGH)]
29 class RecipeRenderer(renderer.abstaining_renderer):
33 name_to_timeout_dict: Dict[str, int],
35 super().__init__(name_to_timeout_dict)
36 self.url_location = url_location
38 def periodic_render(self, key: str) -> bool:
40 if file_utils.does_path_exist(self.url_location):
41 with open(self.url_location, "r") as rf:
44 logger.debug(f"Read {url} from {self.url_location}, writing the page")
46 if url and len(url) > 0:
47 with file_writer.file_writer(RECIPE_PAGE) as f:
48 f.write('<IFRAME SRC="{url}"></IFRAME>')
52 file_utils.remove(RECIPE_PAGE)
53 logger.debug("Signaling the trigger")
54 globals.put("recipe_page_triggered", triggered)