Skip to content

Commit 962ec51

Browse files
authored
utf-8: more debug output when decoding fails (#66)
Now the output includes a representation of the byte sequence that could not be decoded, which aids debugging.
1 parent 601266c commit 962ec51

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modeldb/modelrun.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@ def run_neuron_cmds(model, cmds):
116116
cmds,
117117
stdout=subprocess.PIPE,
118118
stderr=subprocess.STDOUT,
119-
universal_newlines=True,
120119
cwd=model.run_info["start_dir"],
121120
)
122121
out, _ = sp.communicate()
123-
124-
model.nrn_run.extend(curate_log_string(model, out).split('\n'))
122+
try:
123+
out = out.decode("utf-8")
124+
except UnicodeDecodeError:
125+
raise Exception("Could not decode output:" + repr(out))
126+
model.nrn_run.extend(curate_log_string(model, out).splitlines())
125127
if sp.returncode > 1:
126128
model._nrn_run_error = True
127129

0 commit comments

Comments
 (0)