From 44cdf424dc654e7ecb900f582e28e3c022c21790 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Sun, 27 Feb 2022 13:42:10 +0700 Subject: [PATCH] Use create_subprocess_shell --- worthless/linux.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/worthless/linux.py b/worthless/linux.py index 817162b..72cfe1f 100644 --- a/worthless/linux.py +++ b/worthless/linux.py @@ -8,10 +8,10 @@ class LinuxUtils: def __init__(self): pass - async def _exec_command(self, *args): + async def _exec_command(self, args): """Execute a command using pkexec (friendly gui) """ - rsp = await asyncio.create_subprocess_exec(*args) + rsp = await asyncio.create_subprocess_shell(args) await rsp.wait() match rsp.returncode: case 127: @@ -26,11 +26,11 @@ class LinuxUtils: """ if isinstance(file_path, Path): file_path = str(file_path) - await self._exec_command('pkexec', 'echo', text, '>', file_path) + await self._exec_command('pkexec echo {} > {}'.format(text, file_path)) async def append_text_to_file(self, text, file_path: str | Path): """Append text to a file using pkexec (friendly gui) """ if isinstance(file_path, Path): file_path = str(file_path) - await self._exec_command('pkexec', 'echo', text, '>>', file_path) + await self._exec_command('pkexec echo {} >> {}'.format(text, file_path))