Commit 7a2a9856 authored by heemayl's avatar heemayl

Bugfix - hat-parser showing multiple lines when using `-c`/`--command`; fixes #9

parent 40a870df
......@@ -106,6 +106,10 @@ def main():
# expecting .gz extension or as-is
open_ = if file_.endswith('.gz') else open
with open_(file_, mode='rt') as f:
# This keeps track if the line containing
# dt has been printed already; need this
# to handle multiline logs
dt_line_printed = False
for line in f:
line = line.rstrip()
if not line:
......@@ -113,8 +117,9 @@ def main():
# If the line does not start with datetime, it is a
# multiline log so printing it and continuing the
# loop without the datetime comparison
if not
print_msg(line, end='') # log lines already contain blank lines
if (not
if dt_line_printed:
print_msg(line, end='') # log lines already contain blank lines
(run_time_dt, euid, job_id, scheduled_time_dt,
command, return_code, output) = split_format(line)
......@@ -122,9 +127,11 @@ def main():
compare_dt = scheduled_time_dt if compare_sched else run_time_dt
if start_dt <= compare_dt <= end_dt:
print_msg(line, end='')
dt_line_printed = True
# Break out of this file if we're already passed
# the end dt and we're comparing run time
dt_line_printed = False
if not compare_sched and compare_dt > end_dt:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment