From b6e73e733d7470b414d841b1b7a7714d4215d1b1 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Thu, 27 Oct 2016 00:02:56 +0200 Subject: [PATCH] Fix adding server/clientgroup-actions to clients. This was caused, because the used regex was very generic. Therefore it parsed these lines without any problems, a timestamp wasn't added but it was already in the clients-dict, when these checks (conn or disconnect) were performed. --- tsstats/log.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tsstats/log.py b/tsstats/log.py index 5b3bf43..bc5df4d 100644 --- a/tsstats/log.py +++ b/tsstats/log.py @@ -14,7 +14,8 @@ re_log_filename = re.compile(r'ts3server_(?P\d{4}-\d\d-\d\d)' re_log_entry = re.compile('(?P\d{4}-\d\d-\d\d\ \d\d:\d\d:\d\d.\d+)' '\|\ *(?P\w+)\ *\|\ *(?P\w+)\ *' '\|\ *(?P\d+)\ *\|\ *(?P.*)') -re_dis_connect = re.compile(r"'(.*)'\(id:(\d*)\)") +re_dis_connect = re.compile( + r"client (dis)?connected '(?P.*)'\(id:(?P\d+)\)") re_disconnect_invoker = re.compile( r'invokername=(.*)\ invokeruid=(.*)\ reasonmsg' ) @@ -127,7 +128,11 @@ def _parse_details(log_path, ident_map=None, clients=None, online_dc=True): log_timestamp_format) message = match['message'] if message.startswith('client'): - nick, clid = re_dis_connect.findall(message)[0] + match = re_dis_connect.match(message) + if not match: + logger.debug('Not supported client action: "%s"', message) + continue + nick, clid = match.group('nick'), match.group('clid') client = clients.setdefault(clid, Client(clid, nick)) client.nick = nick # set nick to display changes if message.startswith('client connected'):