put internal stats in internal file only
This commit is contained in:
parent
2df50267ab
commit
93e86fbe04
2 changed files with 47 additions and 25 deletions
22
generate.py
22
generate.py
|
@ -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,9 +301,23 @@ 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)
|
||||
|
||||
logging.info(f"Sleeping for {period} seconds.")
|
||||
sleep(period)
|
||||
|
||||
|
|
|
@ -98,30 +98,32 @@
|
|||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h2>Log</h2>
|
||||
<table class="log">
|
||||
{% for entry in log %}
|
||||
<tr>
|
||||
<td>{{entry.ts.strftime("%c")}}</td>
|
||||
<td>
|
||||
{% if entry.state %}
|
||||
<span class="log-in">IN</span>
|
||||
{% else %}
|
||||
<span class="log-out">OUT</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{entry.lease.display}}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{%if internal %}
|
||||
<h2>Log</h2>
|
||||
<table class="log">
|
||||
{% for entry in log %}
|
||||
<tr>
|
||||
<td>{{entry.ts.strftime("%c")}}</td>
|
||||
<td>
|
||||
{% if entry.state %}
|
||||
<span class="log-in">IN</span>
|
||||
{% else %}
|
||||
<span class="log-out">OUT</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{entry.lease.display}}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h2>Leaderboard</h2>
|
||||
<ol>
|
||||
{% for entry in leaderboard %}
|
||||
<li>{{entry.name}} ({{entry.total}})</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
<h2>Leaderboard</h2>
|
||||
<ol>
|
||||
{% for entry in leaderboard %}
|
||||
<li>{{entry.name}} ({{entry.total}})</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue