From 06bfea80bca2e7776713b145ae8ca1951969e0f8 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 9 Apr 2020 11:27:04 +0300 Subject: [PATCH] Fix read file scope --- trains_agent/commands/worker.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/trains_agent/commands/worker.py b/trains_agent/commands/worker.py index 1f8dfd1..b08c414 100644 --- a/trains_agent/commands/worker.py +++ b/trains_agent/commands/worker.py @@ -776,13 +776,13 @@ class Worker(ServiceCommandSection): def _print_file(file_path, prev_line_count): with open(file_path, "rb") as f: binary_text = f.read() - if not binary_text: - return [] - # skip the previously printed lines, - blines = binary_text.split(b'\n')[prev_line_count:] - if not blines: - return blines - return decode_binary_lines(blines if blines[-1] else blines[:-1]) + if not binary_text: + return [] + # skip the previously printed lines, + blines = binary_text.split(b'\n')[prev_line_count:] + if not blines: + return blines + return decode_binary_lines(blines if blines[-1] else blines[:-1]) stdout = open(stdout_path, "wt") stderr = open(stderr_path, "wt") if stderr_path else stdout