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 = "recipe_1_82400.html"
19 RECIPE_PATH = os.path.join(constants.pages_dir, RECIPE_PAGE)
22 class RecipeTrigger(trigger.trigger):
23 def get_triggered_page_list(self) -> Optional[List[Tuple[str, int]]]:
24 if globals.get("recipe_page_triggered"):
25 logger.debug("Recipe page is triggered!")
26 return [(RECIPE_PAGE, trigger.trigger.PRIORITY_HIGH)]
30 class RecipeRenderer(renderer.abstaining_renderer):
34 name_to_timeout_dict: Dict[str, int],
36 super().__init__(name_to_timeout_dict)
37 self.url_location = url_location
39 def periodic_render(self, key: str) -> bool:
41 if file_utils.does_path_exist(self.url_location):
42 with open(self.url_location, "r") as rf:
45 logger.debug(f"Read {url} from {self.url_location}, writing the page")
47 if url and len(url) > 0:
48 with file_writer.file_writer(RECIPE_PATH) as f:
50 f'<IFRAME width="100%" height="100%" frameborder="0" SRC="{url}"></IFRAME>'
55 file_utils.remove(RECIPE_PAGE)
56 logger.debug("Signaling the trigger")
57 globals.put("recipe_page_triggered", triggered)