X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=inline;f=kiosk.py;h=bd7137335ea25e5dbae0d8f39a9226c53c9bb19a;hb=7eae23537dcc61565a24d5c957d4325b7337b63a;hp=6d2fd4e00b5677c3bc8ea1728560ebb5912c6496;hpb=5c39d86ebc075ccb7be98b1dfab8040b72ff9134;p=kiosk.git diff --git a/kiosk.py b/kiosk.py index 6d2fd4e..bd71373 100755 --- a/kiosk.py +++ b/kiosk.py @@ -220,43 +220,48 @@ def thread_change_current(command_queue: Queue) -> None: if triggered: print("chooser[%s] - WE ARE TRIGGERED." % utils.timestamp()) - if page != page_history[0] or (swap_page_target - now < 10.0): + if page != page_history[0] or (swap_page_target - now) < 10.0: print( "chooser[%s] - EMERGENCY PAGE %s LOAD NEEDED" % (utils.timestamp(), page) ) - try: - with open(os.path.join(constants.pages_dir, "current.shtml"), "w") as f: - emit_wrapped(f, page, override_refresh_sec = 40, command = command) - page_history.insert(0, page) - page_history = page_history[0:10] - swap_page_target = now + 40 - except: - print("chooser[%s] - page does not exist?!" % (utils.timestamp())) - continue +# try: + current = os.path.join(constants.pages_dir, "current.shtml") + with open(current, "w") as f: + emit_wrapped(f, page, override_refresh_sec = 40, command = command) + print(f'Wrote {current}') + + page_history.insert(0, page) + page_history = page_history[0:10] + swap_page_target = now + 40 +# except: +# print("chooser[%s] - page does not exist?!" % (utils.timestamp())) +# continue # Also notify XMLHTTP clients that they need to refresh now. - path = os.path.join(constants.pages_dir, "reload_immediately.html") - with open(path, "w") as f: - f.write("Reload, suckers!") + emergency_file = os.path.join(constants.pages_dir, "reload_immediately.html") + with open(emergency_file, "w") as f: + f.write(f'Reload, suckers... you HAVE to see {page}!') + print(f'Causing immediate page reload with {emergency_file}...') # Fix this hack... maybe read the webserver logs and see if it # actually was picked up? - time.sleep(0.75) - os.remove(path) + time.sleep(3.0) + os.remove(emergency_file) + print(f'...and removed {emergency_file}') elif now >= swap_page_target: assert page != page_history[0] print("chooser[%s] - nominal choice of %s" % (utils.timestamp(), page)) - try: - with open(os.path.join(constants.pages_dir, "current.shtml"), "w") as f: - emit_wrapped(f, page) - page_history.insert(0, page) - page_history = page_history[0:10] - swap_page_target = now + constants.refresh_period_sec - except: - print("chooser[%s] - page does not exist?!" % (utils.timestamp())) - continue +# try: + with open(os.path.join(constants.pages_dir, "current.shtml"), "w") as f: + emit_wrapped(f, page) + page_history.insert(0, page) + page_history = page_history[0:10] + swap_page_target = now + constants.refresh_period_sec +# except: +# print("chooser[%s] - page does not exist?!" % (utils.timestamp())) +# continue time.sleep(1) @@ -298,7 +303,7 @@ def emit_wrapped(f, pageid = f'"{command}" -> {filename}' f.write( - """ +"""
|
-
-
+""")
+ f.write(f'')
+ f.write(
+"""
+
-
+ - %s @ %s ago. +""") + f.write(f'{pageid} @ {age} ago.') + f.write( +""" """) def thread_invoke_renderers() -> None: @@ -538,12 +551,13 @@ f''' with file_writer.file_writer(constants.internal_stats_pagename) as f: f.write( f''' -
|