diff options
author | Franck Cuny <franck@fcuny.net> | 2024-03-06 06:29:24 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2024-03-06 06:29:24 -0800 |
commit | 1e4a5aa09c1c8f43722c9c260f011398799a8e8f (patch) | |
tree | cd73e0fb8ba53bd21cee6ccf2dcc85639bbbb93f /tools/dnsmasq-leases-html/dnsmasq-leases-html.py | |
parent | set correct git email in the profiles (diff) | |
download | world-1e4a5aa09c1c8f43722c9c260f011398799a8e8f.tar.gz |
rename `tools` to `packages` to follow convention
The convention is to use `pkgs` or `packages` for overlays and definition of custom packages. Since I'm already using `pkg` for go, I prefer to use `packages` for my scripts.
Diffstat (limited to 'tools/dnsmasq-leases-html/dnsmasq-leases-html.py')
-rwxr-xr-x | tools/dnsmasq-leases-html/dnsmasq-leases-html.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/tools/dnsmasq-leases-html/dnsmasq-leases-html.py b/tools/dnsmasq-leases-html/dnsmasq-leases-html.py deleted file mode 100755 index c1f03db..0000000 --- a/tools/dnsmasq-leases-html/dnsmasq-leases-html.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -import datetime -import ipaddress -import os - -from jinja2 import Environment, FileSystemLoader - - -outfile = os.getenv("DNSMASQ_LEASES_OUT", "/var/lib/dnsmasq/leases.html") -leases_file = os.getenv("DNSMASQ_LEASES", "/var/lib/dnsmasq/dnsmasq.leases") - -leases = [] - -with open(leases_file, "r") as f: - for line in f: - content = line.rstrip("\n").split(" ") - lease = dict() - if int(content[0]) == 0: - lease["expire"] = "never" - else: - lease["expire"] = datetime.datetime.fromtimestamp(int(content[0])) - lease["MAC"] = content[1] - lease["IP"] = ipaddress.ip_address(content[2]) - lease["hostname"] = content[3] - leases.append(lease) - -leases = sorted(leases, key=lambda d: d["IP"]) - -dir_path = os.path.dirname(os.path.realpath(__file__)) -templates_dir = os.path.join(dir_path, "templates") -environment = Environment(loader=FileSystemLoader(templates_dir)) -template = environment.get_template("index.html") - -content = template.render(leases=leases) -with open(outfile, "w") as fh: - print(content, file=fh) |