Use create_subprocess_shell
This commit is contained in:
parent
8f541ff0c4
commit
44cdf424dc
@ -8,10 +8,10 @@ class LinuxUtils:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def _exec_command(self, *args):
|
async def _exec_command(self, args):
|
||||||
"""Execute a command using pkexec (friendly gui)
|
"""Execute a command using pkexec (friendly gui)
|
||||||
"""
|
"""
|
||||||
rsp = await asyncio.create_subprocess_exec(*args)
|
rsp = await asyncio.create_subprocess_shell(args)
|
||||||
await rsp.wait()
|
await rsp.wait()
|
||||||
match rsp.returncode:
|
match rsp.returncode:
|
||||||
case 127:
|
case 127:
|
||||||
@ -26,11 +26,11 @@ class LinuxUtils:
|
|||||||
"""
|
"""
|
||||||
if isinstance(file_path, Path):
|
if isinstance(file_path, Path):
|
||||||
file_path = str(file_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):
|
async def append_text_to_file(self, text, file_path: str | Path):
|
||||||
"""Append text to a file using pkexec (friendly gui)
|
"""Append text to a file using pkexec (friendly gui)
|
||||||
"""
|
"""
|
||||||
if isinstance(file_path, Path):
|
if isinstance(file_path, Path):
|
||||||
file_path = str(file_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))
|
||||||
|
Loading…
Reference in New Issue
Block a user