From 5fb7833677d1460f4edfbf007f80630e498a48cc Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 10 Dec 2023 12:45:23 +0100 Subject: [PATCH] add status command and delete last script --- chatmaild/pyproject.toml | 2 +- deploy-chatmail/pyproject.toml | 3 --- .../src/deploy_chatmail/cmdeploy.py | 23 +++++++++++++++++++ scripts/get_imap_capabilities.py | 14 ----------- 4 files changed, 24 insertions(+), 18 deletions(-) delete mode 100644 scripts/get_imap_capabilities.py diff --git a/chatmaild/pyproject.toml b/chatmaild/pyproject.toml index 190f191..f0481a4 100644 --- a/chatmaild/pyproject.toml +++ b/chatmaild/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61", "setuptools_scm>=6.2"] +requires = ["setuptools>=61"] build-backend = "setuptools.build_meta" [project] diff --git a/deploy-chatmail/pyproject.toml b/deploy-chatmail/pyproject.toml index f251397..7b6b243 100644 --- a/deploy-chatmail/pyproject.toml +++ b/deploy-chatmail/pyproject.toml @@ -19,9 +19,6 @@ dependencies = [ [project.scripts] cmdeploy = "deploy_chatmail.cmdeploy:main" -[tool.setuptools_scm] -write_to = "src/deploy_chatmail/_version.py" - [tool.pytest.ini_options] addopts = "-v -ra --strict-markers" diff --git a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py index ee5340a..5bb9639 100644 --- a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py +++ b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py @@ -81,6 +81,7 @@ def get_parser(): ) add_subcommand(subparsers, dns_cmd) + add_subcommand(subparsers, status_cmd) add_subcommand(subparsers, bench_cmd) add_subcommand(subparsers, test_cmd) add_subcommand(subparsers, webdev_cmd) @@ -112,6 +113,28 @@ def run_cmd(args, out, config): subprocess.check_call(popen_args, env=env) +def status_cmd(args, out, config): + """Display status for online chatmail instance.""" + + ssh = f"ssh root@{config.mailname}" + + def shell_output(arg): + return subprocess.check_output(arg, shell=True).decode() + + out.green(f"chatmail domain: {config.mailname}") + if config.privacy_mail: + out.green("privacy settings: present") + else: + out.red("no privacy settings") + + out(f"[retrieving info by invoking {ssh}]", file=sys.stderr) + + s1 = "systemctl --type=service --state=running" + for line in shell_output(f"{ssh} -- {s1}").split("\n"): + if line.startswith(" "): + print(line) + + def webdev_cmd(args, out, config): """Run local web development loop for static web pages.""" from .www import main diff --git a/scripts/get_imap_capabilities.py b/scripts/get_imap_capabilities.py deleted file mode 100644 index 6b8e171..0000000 --- a/scripts/get_imap_capabilities.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import time -import imaplib - -domain = os.environ.get("CHATMAIL_DOMAIN", "c3.testrun.org") - -print("connecting") -conn = imaplib.IMAP4_SSL(domain) -print("logging in") -conn.login(f"imapcapa", "pass") -status, res = conn.capability() -for capa in sorted(res[0].decode().split()): - print(capa) -