From 61741fe1b20301fb2107652adf0b02dba70dde25 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Tue, 5 Feb 2019 16:06:07 +1100 Subject: rtemstoolkit/execute: Print the trace exe command as a string and not list. --- rtemstoolkit/execute.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'rtemstoolkit') diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py index d509664..35f616c 100755 --- a/rtemstoolkit/execute.py +++ b/rtemstoolkit/execute.py @@ -48,6 +48,7 @@ import traceback from rtemstoolkit import error from rtemstoolkit import log +from rtemstoolkit import stacktraces # Trace exceptions trace_threads = False @@ -174,13 +175,15 @@ class execute(object): #exe.lock.acquire() #exe.outputting = True #exe.lock.release() - if out: - out(prefix + line) - else: - log.output(prefix + line) - if count > 10: - log.flush() - + try: + if out: + out(prefix + line) + else: + log.output(prefix + line) + if count > 10: + log.flush() + except: + stacktraces.trace() if trace_threads: print('execute:_readthread: start') count = 0 @@ -339,17 +342,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 @@ -373,7 +378,6 @@ class execute(object): r, e = os.path.splitext(command[0]) if e not in ['.exe', '.com', '.bat']: command[0] = command[0] + '.exe' - log.trace('exe: %s' % (command)) proc = subprocess.Popen(command, shell = shell, cwd = cwd, env = env, stdin = stdin, stdout = stdout, -- cgit v1.2.3