[rtems-source-builder commit] sb/execute: Port fixes from rtems-tools

Chris Johns chrisj at rtems.org
Sun Mar 29 23:54:30 UTC 2020


Module:    rtems-source-builder
Branch:    master
Commit:    fe63ad8777d597816e36867c3a8b265eaa660804
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=fe63ad8777d597816e36867c3a8b265eaa660804

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Mar 30 10:46:38 2020 +1100

sb/execute: Port fixes from rtems-tools

---

 source-builder/sb/execute.py | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/source-builder/sb/execute.py b/source-builder/sb/execute.py
index 0c25163..06f9b7d 100755
--- a/source-builder/sb/execute.py
+++ b/source-builder/sb/execute.py
@@ -128,12 +128,20 @@ class execute(object):
                 tmp = bytes('temp', sys.stdin.encoding)
             except:
                 encoding = False
+            input_types = [str, bytes]
+            try:
+                # Unicode is not valid in python3, not added to the list
+                input_types += [unicode]
+            except:
+                pass
             try:
                 while True:
                     if trace_threads:
                         print('execute:_writethread: call input', input)
                     lines = input()
-                    if type(lines) == str or type(lines) == bytes:
+                    if trace_threads:
+                        print('execute:_writethread: input returned:', type(lines))
+                    if type(lines) in input_types:
                         try:
                             if encoding:
                                 lines = bytes(lines, sys.stdin.encoding)
@@ -203,6 +211,9 @@ class execute(object):
                     sd = sd[:-1]
                     if len(sd) > 0:
                         for l in sd:
+                            if trace_threads:
+                                print('execute:_readthread: output-line:',
+                                      count, type(l))
                             _output_line(l + '\n', exe, prefix, out, count)
                             count += 1
                         if count > 10:
@@ -329,17 +340,19 @@ class execute(object):
              timeout = None):
         """Open a command with arguments. Provide the arguments as a list or
         a string."""
-        if self.verbose:
-            s = command
-            if type(command) is list:
-                def add(x, y): return x + ' ' + str(y)
-                s = functools.reduce(add, command, '')[1:]
-            what = 'spawn'
-            if shell:
-                what = 'shell'
-            log.output(what + ': ' + s)
         if self.output is None:
             raise error.general('capture needs an output handler')
+        cs = command
+        if type(command) is list:
+            def add(x, y): return x + ' ' + str(y)
+            cs = functools.reduce(add, command, '')[1:]
+        what = 'spawn'
+        if shell:
+            what = 'shell'
+        cs = what + ': ' + cs
+        if self.verbose:
+            log.output(what + ': ' + cs)
+        log.trace('exe: %s' % (cs))
         if shell and self.shell_exe:
             command = arg_list(command)
             command[:0] = self.shell_exe



More information about the vc mailing list