mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Use list everywhere.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user