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.
This commit is contained in:
Thor77 2016-10-27 00:02:56 +02:00
parent 80df2c02f0
commit b6e73e733d
1 changed files with 7 additions and 2 deletions

View File

@ -14,7 +14,8 @@ re_log_filename = re.compile(r'ts3server_(?P<date>\d{4}-\d\d-\d\d)'
re_log_entry = re.compile('(?P<timestamp>\d{4}-\d\d-\d\d\ \d\d:\d\d:\d\d.\d+)' re_log_entry = re.compile('(?P<timestamp>\d{4}-\d\d-\d\d\ \d\d:\d\d:\d\d.\d+)'
'\|\ *(?P<level>\w+)\ *\|\ *(?P<component>\w+)\ *' '\|\ *(?P<level>\w+)\ *\|\ *(?P<component>\w+)\ *'
'\|\ *(?P<sid>\d+)\ *\|\ *(?P<message>.*)') '\|\ *(?P<sid>\d+)\ *\|\ *(?P<message>.*)')
re_dis_connect = re.compile(r"'(.*)'\(id:(\d*)\)") re_dis_connect = re.compile(
r"client (dis)?connected '(?P<nick>.*)'\(id:(?P<clid>\d+)\)")
re_disconnect_invoker = re.compile( re_disconnect_invoker = re.compile(
r'invokername=(.*)\ invokeruid=(.*)\ reasonmsg' r'invokername=(.*)\ invokeruid=(.*)\ reasonmsg'
) )
@ -127,7 +128,11 @@ def _parse_details(log_path, ident_map=None, clients=None, online_dc=True):
log_timestamp_format) log_timestamp_format)
message = match['message'] message = match['message']
if message.startswith('client'): 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 = clients.setdefault(clid, Client(clid, nick))
client.nick = nick # set nick to display changes client.nick = nick # set nick to display changes
if message.startswith('client connected'): if message.startswith('client connected'):