From 32e060daa495da1d369936ed95b50bcb65ce50ac Mon Sep 17 00:00:00 2001 From: Thor77 Date: Mon, 22 Jun 2015 16:25:36 +0200 Subject: [PATCH] fix for handling some not dis/connect lines --- tsstats.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tsstats.py b/tsstats.py index 3b44b14..4f5399d 100755 --- a/tsstats.py +++ b/tsstats.py @@ -160,6 +160,14 @@ for log_file in log_files: for line in open(log_file, 'r'): log_lines.append(line) + +def get_client(clid): + if clid in id_map: + clid = id_map[clid] + client = clients[clid] + client.nick = nick + return client + # process lines for line in log_lines: parts = line.split('|') @@ -167,13 +175,11 @@ for line in log_lines: data = '|'.join(parts[4:]).strip() if data.startswith('client'): nick, clid = re_dis_connect.findall(data)[0] - if clid in id_map: - clid = id_map[clid] - client = clients[clid] - client.nick = nick if data.startswith('client connected'): + client = get_client(clid) client.connect(logdatetime) elif data.startswith('client disconnected'): + client = get_client(clid) client.disconnect(logdatetime) if 'invokeruid' in data: re_disconnect_data = re_disconnect_invoker.findall(data)