More changes related to running on new kiosk.house.
[kiosk.git] / health_renderer.py
index 038e315c48144435255cec9720e1b90be0e731fa..3c4c30c02ce2a0b01e633f6bd759ead3285e57ce 100644 (file)
@@ -52,7 +52,7 @@ class periodic_health_renderer(renderer.debuggable_abstaining_renderer):
                 timestamps + "last_backup_disk_selftest_long": days * 31,
                 timestamps + "last_cabin_disk_selftest_short": days * 14,
                 timestamps + "last_cabin_disk_selftest_long": days * 31,
-                timestamps + "last_cabin_rpi_ping": mins * 10,
+                timestamps + "last_cabin_rpi_ping": mins * 20,
                 timestamps + "last_healthy_wifi": mins * 10,
                 timestamps + "last_healthy_network": mins * 10,
                 timestamps + "last_scott_sync": days * 2,
@@ -61,27 +61,31 @@ class periodic_health_renderer(renderer.debuggable_abstaining_renderer):
 
             now = time.time()
             n = 0
-            for x in sorted(limits):
-                ts = os.stat(x).st_mtime
+            for filepath, limit_sec in sorted(limits.items()):
+                ts = os.stat(filepath).st_mtime
                 age = now - ts
-                self.debug_print("%s -- age is %ds, limit is %ds" % (x, age, limits[x]))
-                if age < limits[x]:
+                self.debug_print(f"{filepath} -- age: {age}, limit {limit_sec}")
+                if age < limits[filepath]:
+                    # OK
                     f.write(
-                        '<TD BGCOLOR="#007010" HEIGHT=100 WIDTH=33% STYLE="text-size:60%; vertical-align: middle;">\n'
+                        '<TD BGCOLOR="#007010" HEIGHT=100 WIDTH=33% STYLE="text-size:70%; vertical-align: middle;">\n'
                     )
+                    txt_color="#ffffff"
                 else:
+                    # BAD!
                     f.write(
-                        '<TD BGCOLOR="#990000" HEIGHT=100 WIDTH=33% CLASS="invalid" STYLE="text-size:60%; vertical-align:middle;">\n'
+                        '<TD BGCOLOR="#990000" HEIGHT=100 WIDTH=33% CLASS="invalid" STYLE="text-size:70%; vertical-align:middle;">\n'
                     )
-                f.write("  <CENTER><FONT SIZE=-2>\n")
+                    txt_color="#000000"
+                f.write(f"  <CENTER><FONT SIZE=-1 COLOR={txt_color}>\n")
 
-                name = x.replace(timestamps, "")
+                name = filepath.replace(timestamps, "")
                 name = name.replace("last_", "")
                 name = name.replace("_", "&nbsp;")
                 duration = utils.describe_duration_briefly(int(age))
 
                 self.debug_print(f"{name} is {duration} old.")
-                f.write(f"{name}<BR>\n<B>{ts}</B> old.\n")
+                f.write(f"{name}<BR>\n<B>{duration}</B> old.\n")
                 f.write("</FONT></CENTER>\n</TD>\n\n")
                 n += 1
                 if n % 3 == 0:
@@ -151,5 +155,5 @@ class periodic_health_renderer(renderer.debuggable_abstaining_renderer):
         )
 
 
-# test = periodic_health_renderer({"Test", 123})
-# test.periodic_render("Test")
+#test = periodic_health_renderer({"Test", 123})
+#test.periodic_render("Test")