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("_", " ")
- ts = utils.describe_duration_briefly(age)
+ duration = utils.describe_duration_briefly(int(age))
- self.debug_print(f"{name} is {ts} old.")
- f.write(f"{name}<BR>\n<B>{ts}</B> old.\n")
+ self.debug_print(f"{name} is {duration} old.")
+ 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:
)
-# test = periodic_health_renderer({"Test", 123})
-# test.periodic_render("Test")
+#test = periodic_health_renderer({"Test", 123})
+#test.periodic_render("Test")