+ page_chooser = chooser.weighted_random_chooser_with_triggers(
+ trigger_catalog.get_triggers(), [filter_news_during_dinnertime]
+ )
+ current_file = os.path.join(kiosk_constants.pages_dir, "current.shtml")
+ emergency_file = os.path.join(kiosk_constants.pages_dir, "reload_immediately.html")
+
+ # Main chooser loop -- note that this executes a couple of times per second
+ # to be responsive to triggers.
+ while True:
+ now = time.time()
+ page = None
+ triggered = False
+ command = None
+
+ # Is there a verbal command to parse?
+ (page, command) = check_for_command()
+ if page and command:
+ triggered = True
+ else:
+ # If not, choose the a (new!) page randomly or respond to a trigger.
+ (page, triggered) = choose_page_randomly()
+
+ # By now we have a page and we may be triggered.