mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
*: Use action_utils.run instead of subprocess.run
- This is to capture stdout and stderr and transmit that from privileged daemon back to the service to be displayed in HTML. Tests: - Unit tests and code checks pass. - Some of the modified actions work as expected. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
1 parent
355812c9f2
commit
61ff15a04f
36 files changed
+257
-244
No files matched your search
@@ -7,7 +7,7 @@ import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from plinth import utils
|
||||
from plinth import action_utils, utils
|
||||
from plinth.actions import privileged
|
||||
from plinth.db import postgres
|
||||
from plinth.modules.email.privileged.domain import \
|
||||
@@ -144,8 +144,8 @@ def set_domain(domain: str):
|
||||
|
||||
def _get_config_value(key: str) -> str:
|
||||
"""Return the value of a property from the configuration file."""
|
||||
process = subprocess.run(['plget', key], input=CONFIG_FILE.read_bytes(),
|
||||
stdout=subprocess.PIPE, check=True)
|
||||
process = action_utils.run(['plget', key], input=CONFIG_FILE.read_bytes(),
|
||||
stdout=subprocess.PIPE, check=True)
|
||||
return process.stdout.decode().strip()
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ def _set_config_value(key: str, value: str):
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
temp_file.write(f'{{\n{key} = "{value}";\n}}'.encode('utf-8'))
|
||||
temp_file.close()
|
||||
subprocess.run(['plmerge', CONFIG_FILE, temp_file.name], check=True)
|
||||
action_utils.run(['plmerge', CONFIG_FILE, temp_file.name], check=True)
|
||||
pathlib.Path(temp_file.name).unlink()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user