[rtems-tools commit] rtemstoolkit: Provide a shlex.join for python 3.8 and earlier
Chris Johns
chrisj at rtems.org
Wed Aug 30 22:55:19 UTC 2023
Module: rtems-tools
Branch: master
Commit: eda9325e583f761c53ee3db83124cc77cb4fefb5
Changeset: http://git.rtems.org/rtems-tools/commit/?id=eda9325e583f761c53ee3db83124cc77cb4fefb5
Author: Chris Johns <chrisj at rtems.org>
Date: Wed Aug 30 09:51:47 2023 +1000
rtemstoolkit: Provide a shlex.join for python 3.8 and earlier
---
rtemstoolkit/execute.py | 12 ++++++++++--
1 file 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'
More information about the vc
mailing list