summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-08-30 09:51:47 +1000
committerChris Johns <chrisj@rtems.org>2023-08-30 09:51:47 +1000
commiteda9325e583f761c53ee3db83124cc77cb4fefb5 (patch)
tree49d71dec3f8feedc7e008988c27192e30a0e2d62
parentrtemstoolkit: Fix shell execution (diff)
downloadrtems-tools-eda9325e583f761c53ee3db83124cc77cb4fefb5.tar.bz2
rtemstoolkit: Provide a shlex.join for python 3.8 and earlier
-rwxr-xr-xrtemstoolkit/execute.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py
index d183b14..31d3a8a 100755
--- a/rtemstoolkit/execute.py
+++ b/rtemstoolkit/execute.py
@@ -125,6 +125,14 @@ class execute(object):
self.timing_out = False
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):
"""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
@@ -360,11 +368,11 @@ class execute(object):
if not shell and isinstance(command, str):
command = shlex.split(command)
if shell and isinstance(command, list):
- command = shlex.join(command)
+ command = execute._shlex_join(command)
if self.shell_exe:
command = self.shell_exe + ' ' + command
if isinstance(command, list):
- cs = shlex.join(command)
+ cs = execute._shlex_join(command)
else:
cs = command
what = 'spawn'