1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-21 00:19:42 +02:00

fixes for from and comment fields

This commit is contained in:
Kelly Brazil
2020-03-01 16:49:52 -08:00
parent 07c1be9e9a
commit f9982a7947

View File

@ -149,6 +149,11 @@ def parse(data, raw=False, quiet=False):
output_line['time'] = ' '.join([linedata.pop(0),
linedata.pop(0)])
# if just one more field, then it's the remote IP
if len(linedata) == 1:
output_line['from'] = linedata[0].replace('(', '').replace(')', '')
continue
# extended info: idle
if len(linedata) > 0:
output_line['idle'] = linedata.pop(0)
@ -157,8 +162,12 @@ def parse(data, raw=False, quiet=False):
if len(linedata) > 0:
output_line['pid'] = linedata.pop(0)
# extended info: comment
if len(linedata) > 0:
# extended info is from
if len(linedata) > 0 and linedata[0].startswith('('):
output_line['from'] = linedata[0].replace('(', '').replace(')', '')
# else, extended info is comment
elif len(linedata) > 0:
output_line['comment'] = ' '.join(linedata)
raw_output.append(output_line)