mirror of
https://git.rtems.org/rtems-tools/
synced 2025-05-14 04:29:17 +08:00
rtemstoolkit: Provide a shlex.join for python 3.8 and earlier
This commit is contained in:
parent
3ea0c24934
commit
eda9325e58
@ -125,6 +125,14 @@ class execute(object):
|
|||||||
self.timing_out = False
|
self.timing_out = False
|
||||||
self.proc = None
|
self.proc = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _shlex_join(elements):
|
||||||
|
try:
|
||||||
|
return shlex.join(elements)
|
||||||
|
except AttributeError:
|
||||||
|
# Python older than 3.8 does not have shlex.join
|
||||||
|
return ' '.join(elements)
|
||||||
|
|
||||||
def capture(self, proc, command = 'pipe', timeout = None):
|
def capture(self, proc, command = 'pipe', timeout = None):
|
||||||
"""Create 3 threads to read stdout and stderr and send to the output handler
|
"""Create 3 threads to read stdout and stderr and send to the output handler
|
||||||
and call an input handler is provided. Based on the 'communicate' code
|
and call an input handler is provided. Based on the 'communicate' code
|
||||||
@ -360,11 +368,11 @@ class execute(object):
|
|||||||
if not shell and isinstance(command, str):
|
if not shell and isinstance(command, str):
|
||||||
command = shlex.split(command)
|
command = shlex.split(command)
|
||||||
if shell and isinstance(command, list):
|
if shell and isinstance(command, list):
|
||||||
command = shlex.join(command)
|
command = execute._shlex_join(command)
|
||||||
if self.shell_exe:
|
if self.shell_exe:
|
||||||
command = self.shell_exe + ' ' + command
|
command = self.shell_exe + ' ' + command
|
||||||
if isinstance(command, list):
|
if isinstance(command, list):
|
||||||
cs = shlex.join(command)
|
cs = execute._shlex_join(command)
|
||||||
else:
|
else:
|
||||||
cs = command
|
cs = command
|
||||||
what = 'spawn'
|
what = 'spawn'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user