put internal stats in internal file only

This commit is contained in:
Tomáš Mládek 2022-01-03 20:14:51 +01:00
parent 2df50267ab
commit 93e86fbe04
2 changed files with 47 additions and 25 deletions

View file

@ -95,8 +95,14 @@ def _is_human(lease: Lease):
)
@click.option("--webhook-url", help="Webhook URL to post status changes to.")
@click.option("-o", "--output", multiple=True, help="Output file.")
@click.option("--output-internal", help="Output file (with internal stats).")
def run_forever(
address: str, period: int, ssid: str, output: str, webhook_url: Optional[str]
address: str,
period: int,
ssid: str,
output: str,
output_internal: Optional[str],
webhook_url: Optional[str],
):
logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - [%(levelname)s] %(message)s"
@ -295,6 +301,20 @@ def run_forever(
last_change=last_change,
log=log,
leaderboard=leaderboard,
internal=False,
)
file.write(out_str)
if output_internal:
with open(output_internal, "w") as file:
out_str = jinja_env.get_template("index.html").render(
now=now,
leases=registered_leases,
status=status,
last_change=last_change,
log=log,
leaderboard=leaderboard,
internal=True,
)
file.write(out_str)

View file

@ -98,6 +98,7 @@
{% endfor %}
</table>
{%if internal %}
<h2>Log</h2>
<table class="log">
{% for entry in log %}
@ -123,5 +124,6 @@
<li>{{entry.name}} ({{entry.total}})</li>
{% endfor %}
</ol>
{% endif %}
</body>
</html>