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
@@ -6,12 +6,14 @@ Uses utilities from 'mysql-client' package such as 'mysql' and 'mysqldump'.
|
||||
|
||||
import subprocess
|
||||
|
||||
from .. import action_utils
|
||||
|
||||
|
||||
def run_query(database_name: str, query: str) -> subprocess.CompletedProcess:
|
||||
"""Run a database query using 'root' user.
|
||||
|
||||
Does not ensure that the database server is running.
|
||||
"""
|
||||
return subprocess.run(
|
||||
return action_utils.run(
|
||||
['mysql', '--user=root', '--database', database_name],
|
||||
input=query.encode('utf-8'), check=True)
|
||||
@@ -6,7 +6,6 @@ Uses utilities from 'postgres' package such as 'psql' and 'pg_dump'.
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
from plinth import action_utils
|
||||
|
||||
@@ -14,7 +13,7 @@ from plinth import action_utils
|
||||
def _run_as(command, **kwargs):
|
||||
"""Run a command as 'postgres' user."""
|
||||
command = ['sudo', '--user', 'postgres'] + command
|
||||
return subprocess.run(command, check=True, **kwargs)
|
||||
return action_utils.run(command, check=True, **kwargs)
|
||||
|
||||
|
||||
def run_query(query):
|
||||
|
||||
Reference in new issue
Block a user