add status command and delete last script

This commit is contained in:
holger krekel 2023-12-10 12:45:23 +01:00
parent 587d8142d2
commit 5fb7833677
4 changed files with 24 additions and 18 deletions

View File

@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=61", "setuptools_scm>=6.2"]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"
[project]

View File

@ -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"

View File

@ -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

View File

@ -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)