From 5ff618eee80cf3f955c8a88c14298383da24ed0d Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Mon, 9 May 2022 17:57:08 +0000 Subject: [PATCH] communicate install status to the plugin Signed-off-by: Xe Iaso --- main.py | 9 +++++---- main_view.html | 8 +------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index cc8f4af..a4bd253 100644 --- a/main.py +++ b/main.py @@ -9,17 +9,18 @@ class Plugin: def _systemd_status(self, service = "tailscaled.service"): result = subprocess.run(["/bin/sh", "-c", "systemctl status tailscaled.service | grep active"], stdout=subprocess.PIPE) - return result.stdout.decode("utf-8").split(": ")[1] + return result.stdout.decode("utf-8").split(": ")[1].strip() async def install_state(self, *args): + print("got here") sysext = subprocess.run(["/usr/bin/systemd-sysext", "list", "--json=short"], stdout=subprocess.PIPE) - sysexts = json.load(sysext.stdout.decode("utf-8")) + sysexts = json.loads(sysext.stdout.decode("utf-8")) - if sysexts.len() == 0: + if len(sysexts) == 0: return "not installed" for ext in sysexts: - if ext.name != "tailscale": + if ext["name"] != "tailscale": continue return self._systemd_status() diff --git a/main_view.html b/main_view.html index 09b56f2..43a9cf2 100644 --- a/main_view.html +++ b/main_view.html @@ -14,11 +14,6 @@ } async function onReady() { - let heading = document.getElementById("heading"); - let id = await getUID(); - - heading.innerText = `Hello ${id}`; - let status = document.getElementById("status"); let install_status = await getInstallState(); @@ -27,7 +22,6 @@ -

Hello World

-

Status: loading

+

Status: loading