Fix execution output handling

This commit is contained in:
allegroai 2020-03-20 10:35:25 +02:00
parent ea0ed4807e
commit 58ab67ea31

View File

@ -763,9 +763,13 @@ class Worker(ServiceCommandSection):
def _print_file(file_path, prev_line_count): def _print_file(file_path, prev_line_count):
with open(file_path, "rb") as f: with open(file_path, "rb") as f:
binary_text = f.read() binary_text = f.read()
if not binary_text:
return []
# skip the previously printed lines, # skip the previously printed lines,
blines = binary_text.split(b'\n')[prev_line_count:] blines = binary_text.split(b'\n')[prev_line_count:]
return decode_binary_lines(blines) if not blines:
return blines
return decode_binary_lines(blines if blines[-1] else blines[:-1])
stdout = open(stdout_path, "wt") stdout = open(stdout_path, "wt")
stderr = open(stderr_path, "wt") if stderr_path else stdout stderr = open(stderr_path, "wt") if stderr_path else stdout