Skip to content

Commit

Permalink
Merge pull request #295 from climbfuji/fix_decoding_errors_stampede
Browse files Browse the repository at this point in the history
Fix decoding errors in scripts/common.py's execute_cmd
  • Loading branch information
climbfuji authored Jun 1, 2020
2 parents 7c3673d + a477b63 commit d31bdb7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,19 @@ def execute(cmd, abort = True):
status = p.returncode
if debug:
message = 'Execution of "{0}" returned with exit code {1}\n'.format(cmd, status)
message += ' stdout: "{0}"\n'.format(stdout.decode('ascii').rstrip('\n'))
message += ' stderr: "{0}"'.format(stderr.decode('ascii').rstrip('\n'))
message += ' stdout: "{0}"\n'.format(stdout.decode(encoding='ascii', errors='ignore').rstrip('\n'))
message += ' stderr: "{0}"'.format(stderr.decode(encoding='ascii', errors='ignore').rstrip('\n'))
logging.debug(message)
if not status == 0:
message = 'Execution of command {0} failed, exit code {1}\n'.format(cmd, status)
message += ' stdout: "{0}"\n'.format(stdout.decode('ascii').rstrip('\n'))
message += ' stderr: "{0}"'.format(stderr.decode('ascii').rstrip('\n'))
message += ' stdout: "{0}"\n'.format(stdout.decode(encoding='ascii', errors='ignore').rstrip('\n'))
message += ' stderr: "{0}"'.format(stderr.decode(encoding='ascii', errors='ignore').rstrip('\n'))
if abort:
raise Exception(message)
else:
logging.error(message)
return (status, stdout.decode('ascii').rstrip('\n'), stderr.decode('ascii').rstrip('\n'))
return (status, stdout.decode(encoding='ascii', errors='ignore').rstrip('\n'),
stderr.decode(encoding='ascii', errors='ignore').rstrip('\n'))

def split_var_name_and_array_reference(var_name):
"""Split an expression like foo(:,a,1:ddt%ngas)
Expand Down

0 comments on commit d31bdb7

Please sign in to comment.