From 17961e1bf7a104b4eaa146996a112e3e7ccf0a9e Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 23 Feb 2026 02:59:07 +0100 Subject: [PATCH] revert pure whitespace chagnes --- cmdeploy/src/cmdeploy/acmetool/__init__.py | 2 +- cmdeploy/src/cmdeploy/cmdeploy.py | 10 ++----- cmdeploy/src/cmdeploy/deployers.py | 10 ++----- cmdeploy/src/cmdeploy/dovecot/deployer.py | 6 +--- cmdeploy/src/cmdeploy/postfix/deployer.py | 12 +++----- cmdeploy/src/cmdeploy/selfsigned/deployer.py | 29 +++++-------------- .../src/cmdeploy/tests/online/test_0_qr.py | 17 +++++------ .../cmdeploy/tests/online/test_2_deltachat.py | 2 +- cmdeploy/src/cmdeploy/tests/plugin.py | 9 ++---- 9 files changed, 29 insertions(+), 68 deletions(-) diff --git a/cmdeploy/src/cmdeploy/acmetool/__init__.py b/cmdeploy/src/cmdeploy/acmetool/__init__.py index e0e8c02f..e4e1ed84 100644 --- a/cmdeploy/src/cmdeploy/acmetool/__init__.py +++ b/cmdeploy/src/cmdeploy/acmetool/__init__.py @@ -67,7 +67,7 @@ class AcmetoolDeployer(Deployer): ) files.template( src=importlib.resources.files(__package__).joinpath("desired.yaml.j2"), - dest=f"/var/lib/acme/desired/{self.domains[0]}", # 0 is mailhost TLD + dest=f"/var/lib/acme/desired/{self.domains[0]}", # 0 is mailhost TLD user="root", group="root", mode="644", diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index 85017c9b..a7ed5fee 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -93,9 +93,7 @@ def run_cmd(args, out): strict_tls = args.config.tls_cert_mode == "acme" if not args.dns_check_disabled: remote_data = dns.get_initial_remote_data(sshexec, args.config.mail_domain) - if not dns.check_initial_remote_data( - remote_data, strict_tls=strict_tls, print=out.red - ): + if not dns.check_initial_remote_data(remote_data, strict_tls=strict_tls, print=out.red): return 1 env = os.environ.copy() @@ -129,11 +127,7 @@ def run_cmd(args, out): out.red("Website deployment failed.") elif retcode == 0: out.green("Deploy completed, call `cmdeploy dns` next.") - elif ( - not args.dns_check_disabled - and strict_tls - and not remote_data["acme_account_url"] - ): + elif not args.dns_check_disabled and strict_tls and not remote_data["acme_account_url"]: out.red("Deploy completed but letsencrypt not configured") out.red("Run 'cmdeploy run' again") retcode = 0 diff --git a/cmdeploy/src/cmdeploy/deployers.py b/cmdeploy/src/cmdeploy/deployers.py index 31e87f66..897ae6f0 100644 --- a/cmdeploy/src/cmdeploy/deployers.py +++ b/cmdeploy/src/cmdeploy/deployers.py @@ -579,17 +579,11 @@ def deploy_chatmail(config_path: Path, disable_mail: bool, website_only: bool) - ) # Check if mtail_address interface is available (if configured) - if config.mtail_address and config.mtail_address not in ( - "127.0.0.1", - "::1", - "localhost", - ): + if config.mtail_address and config.mtail_address not in ('127.0.0.1', '::1', 'localhost'): ipv4_addrs = host.get_fact(hardware.Ipv4Addrs) all_addresses = [addr for addrs in ipv4_addrs.values() for addr in addrs] if config.mtail_address not in all_addresses: - Out().red( - f"Deploy failed: mtail_address {config.mtail_address} is not available (VPN up?).\n" - ) + Out().red(f"Deploy failed: mtail_address {config.mtail_address} is not available (VPN up?).\n") exit(1) if not os.environ.get("CHATMAIL_NOPORTCHECK"): diff --git a/cmdeploy/src/cmdeploy/dovecot/deployer.py b/cmdeploy/src/cmdeploy/dovecot/deployer.py index 302a5510..bb3bd764 100644 --- a/cmdeploy/src/cmdeploy/dovecot/deployer.py +++ b/cmdeploy/src/cmdeploy/dovecot/deployer.py @@ -42,11 +42,7 @@ class DovecotDeployer(Deployer): restart = False if self.disable_mail else self.need_restart systemd.service( - name=( - "Disable dovecot for now" - if self.disable_mail - else "Start and enable Dovecot" - ), + name="Disable dovecot for now" if self.disable_mail else "Start and enable Dovecot", service="dovecot.service", running=False if self.disable_mail else True, enabled=False if self.disable_mail else True, diff --git a/cmdeploy/src/cmdeploy/postfix/deployer.py b/cmdeploy/src/cmdeploy/postfix/deployer.py index 1f9c2652..96197bd7 100644 --- a/cmdeploy/src/cmdeploy/postfix/deployer.py +++ b/cmdeploy/src/cmdeploy/postfix/deployer.py @@ -97,9 +97,7 @@ class PostfixDeployer(Deployer): server.shell( name="Validate postfix configuration", # Extract stderr and quit with error if non-zero - commands=[ - """bash -c 'w=$(postconf 2>&1 >/dev/null); [[ -z "$w" ]] || { echo "$w"; false; }'""" - ], + commands=["""bash -c 'w=$(postconf 2>&1 >/dev/null); [[ -z "$w" ]] || { echo "$w"; false; }'"""], ) self.need_restart = need_restart @@ -107,11 +105,9 @@ class PostfixDeployer(Deployer): restart = False if self.disable_mail else self.need_restart systemd.service( - name=( - "disable postfix for now" - if self.disable_mail - else "Start and enable Postfix" - ), + name="disable postfix for now" + if self.disable_mail + else "Start and enable Postfix", service="postfix.service", running=False if self.disable_mail else True, enabled=False if self.disable_mail else True, diff --git a/cmdeploy/src/cmdeploy/selfsigned/deployer.py b/cmdeploy/src/cmdeploy/selfsigned/deployer.py index 17d04f07..0faff5e8 100644 --- a/cmdeploy/src/cmdeploy/selfsigned/deployer.py +++ b/cmdeploy/src/cmdeploy/selfsigned/deployer.py @@ -12,24 +12,13 @@ def openssl_selfsigned_args(domain, cert_path, key_path, days=36500): ``www.`` and ``mta-sts.``. """ return [ - "openssl", - "req", - "-x509", - "-newkey", - "ec", - "-pkeyopt", - "ec_paramgen_curve:P-256", - "-noenc", - "-days", - str(days), - "-keyout", - str(key_path), - "-out", - str(cert_path), - "-subj", - f"/CN={domain}", - "-addext", - "extendedKeyUsage=serverAuth,clientAuth", + "openssl", "req", "-x509", + "-newkey", "ec", "-pkeyopt", "ec_paramgen_curve:P-256", + "-noenc", "-days", str(days), + "-keyout", str(key_path), + "-out", str(cert_path), + "-subj", f"/CN={domain}", + "-addext", "extendedKeyUsage=serverAuth,clientAuth", "-addext", f"subjectAltName=DNS:{domain},DNS:www.{domain},DNS:mta-sts.{domain}", ] @@ -51,9 +40,7 @@ class SelfSignedTlsDeployer(Deployer): def configure(self): args = openssl_selfsigned_args( - self.mail_domain, - self.cert_path, - self.key_path, + self.mail_domain, self.cert_path, self.key_path, ) cmd = shlex.join(args) server.shell( diff --git a/cmdeploy/src/cmdeploy/tests/online/test_0_qr.py b/cmdeploy/src/cmdeploy/tests/online/test_0_qr.py index 4ffc8f0d..b916e696 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_0_qr.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_0_qr.py @@ -30,15 +30,12 @@ def test_newemail_configure(maildomain, rpc, chatmail_config): # set_config_from_qr, so fetch credentials via requests instead res = requests.post(f"https://{maildomain}/new", verify=False) data = res.json() - rpc.add_or_update_transport( - account_id, - { - "addr": data["email"], - "password": data["password"], - "imapServer": maildomain, - "smtpServer": maildomain, - "certificateChecks": "acceptInvalidCertificates", - }, - ) + rpc.add_or_update_transport(account_id, { + "addr": data["email"], + "password": data["password"], + "imapServer": maildomain, + "smtpServer": maildomain, + "certificateChecks": "acceptInvalidCertificates", + }) else: rpc.add_transport_from_qr(account_id, url) diff --git a/cmdeploy/src/cmdeploy/tests/online/test_2_deltachat.py b/cmdeploy/src/cmdeploy/tests/online/test_2_deltachat.py index 947c34f9..53e3846a 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_2_deltachat.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_2_deltachat.py @@ -6,8 +6,8 @@ import imap_tools import pytest import requests -from cmdeploy.cmdeploy import get_sshexec from cmdeploy.remote import rshell +from cmdeploy.cmdeploy import get_sshexec @pytest.fixture diff --git a/cmdeploy/src/cmdeploy/tests/plugin.py b/cmdeploy/src/cmdeploy/tests/plugin.py index f0a27b31..34f258df 100644 --- a/cmdeploy/src/cmdeploy/tests/plugin.py +++ b/cmdeploy/src/cmdeploy/tests/plugin.py @@ -399,12 +399,9 @@ class Remote: getjournal = "journalctl -f" if not logcmd else logcmd print(self.sshdomain) match self.sshdomain: - case "@local": - command = [] - case "localhost": - command = [] - case _: - command = ["ssh", f"root@{self.sshdomain}"] + case "@local": command = [] + case "localhost": command = [] + case _: command = ["ssh", f"root@{self.sshdomain}"] [command.append(arg) for arg in getjournal.split()] self.popen = subprocess.Popen( command,