Use list everywhere.

This commit is contained in:
Antoine Nguyen
2026-02-21 09:39:30 +01:00
parent a2cf6e4cb8
commit 5730213083
2 changed files with 14 additions and 10 deletions
+2 -6
View File
@@ -14,7 +14,7 @@ from django.utils.encoding import force_str
def exec_cmd(
cmd: str | list[str],
cmd: list[str],
sudo_user: str | None = None,
pinput: str | None = None,
capture_output: bool = True,
@@ -33,11 +33,7 @@ def exec_cmd(
:return: return code, command output
"""
if sudo_user is not None:
if isinstance(cmd, list):
cmd = ["sudo", "-u", sudo_user] + cmd
else:
cmd = f"sudo -u {sudo_user} {cmd}"
cmd = ["sudo", "-u", sudo_user] + cmd
if pinput is not None:
kwargs["stdin"] = subprocess.PIPE
if capture_output:
+12 -4
View File
@@ -26,10 +26,18 @@ class DeployTest(unittest.TestCase):
def test_silent(self):
dburl = f"default:{self.dbtype}://{self.dbuser}:{self.dbpassword}@{self.dbhost}:{self.dbport}/modoboa"
cmd = (
f"modoboa-admin.py deploy --collectstatic "
f"--dburl {dburl} --domain localhost --admin-username admin {self.projname}"
)
cmd = [
"modoboa-admin.py",
"deploy",
"--collectstatic",
"--dburl",
dburl,
"--domain",
"localhost",
"--admin-username",
"admin",
self.projname,
]
code, output = exec_cmd(cmd, cwd=self.workdir, shell=True)
self.assertEqual(code, 0)