updated analyze code to use chat.log
added system messages - albeit it does not determine sub-stuff chat log still needs to eat following packets
This commit is contained in:
parent
e43065cc00
commit
1016085bed
21
analyze.py
21
analyze.py
@ -29,8 +29,9 @@ if __name__ == '__main__':
|
|||||||
#f = open('output.txt', 'w')
|
#f = open('output.txt', 'w')
|
||||||
rex_combat = {}
|
rex_combat = {}
|
||||||
rex_game = {}
|
rex_game = {}
|
||||||
|
rex_chat = {}
|
||||||
for logf in coll.sessions:
|
for logf in coll.sessions:
|
||||||
logf.parse_files(['game.log', 'combat.log'])
|
logf.parse_files(['game.log', 'combat.log', 'chat.log'])
|
||||||
print "----- Log %s -----" % logf.idstr
|
print "----- Log %s -----" % logf.idstr
|
||||||
if logf.combat_log:
|
if logf.combat_log:
|
||||||
for l in logf.combat_log.lines:
|
for l in logf.combat_log.lines:
|
||||||
@ -54,12 +55,22 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
rex_game[l.__class__.__name__] = rex_game.get(l.__class__.__name__, 0) + 1
|
rex_game[l.__class__.__name__] = rex_game.get(l.__class__.__name__, 0) + 1
|
||||||
print l.values['log']
|
print l.values['log']
|
||||||
# ClientInfo introspection for ping
|
if logf.chat_log:
|
||||||
#if isinstance(l, ClientInfo) and l.values.get('clinfo', '') == 'avgPing':
|
for l in logf.chat_log.lines:
|
||||||
# print l.values
|
if isinstance(l, dict):
|
||||||
# # fix avgPing parsing!
|
rex_chat['dict'] = rex_chat.get('dict', 0) + 1
|
||||||
|
elif isinstance(l, str):
|
||||||
|
print l
|
||||||
|
else:
|
||||||
|
if l.unpack():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
rex_chat[l.__class__.__name__] = rex_chat.get(l.__class__.__name__, 0) + 1
|
||||||
|
print l.values['log']
|
||||||
print 'Analysis complete:'
|
print 'Analysis complete:'
|
||||||
print '#'*20+' RexCombat ' + '#' *20
|
print '#'*20+' RexCombat ' + '#' *20
|
||||||
print rex_combat
|
print rex_combat
|
||||||
print '#'*20+' RexGame ' + '#' *20
|
print '#'*20+' RexGame ' + '#' *20
|
||||||
print rex_game
|
print rex_game
|
||||||
|
print '#'*20+' RexChat ' + '#' *20
|
||||||
|
print rex_chat
|
||||||
|
15
logs/chat.py
15
logs/chat.py
@ -24,6 +24,7 @@ class ChatLog(Log):
|
|||||||
|
|
||||||
def __init__(self, values=None):
|
def __init__(self, values=None):
|
||||||
self.values = values or {}
|
self.values = values or {}
|
||||||
|
self.reviewed = False
|
||||||
|
|
||||||
def unpack(self, force=False):
|
def unpack(self, force=False):
|
||||||
if self.reviewed and not force:
|
if self.reviewed and not force:
|
||||||
@ -48,6 +49,19 @@ class ChatLog(Log):
|
|||||||
''' returns a String readable by humans explaining this Log '''
|
''' returns a String readable by humans explaining this Log '''
|
||||||
return self.values.get('log', 'Unknown Chat Log')
|
return self.values.get('log', 'Unknown Chat Log')
|
||||||
|
|
||||||
|
class SystemMessage(ChatLog):
|
||||||
|
matcher = re.compile(r"^<\s+SYSTEM>\s(?P<message>.*)")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _is_handler(cls, log):
|
||||||
|
if log.get('log', '').lstrip().startswith('< SYSTEM>'):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def explain(self):
|
||||||
|
return '[SYSTEM]: %(message)s' % self.values
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PrivateMessageReceived(ChatLog):
|
class PrivateMessageReceived(ChatLog):
|
||||||
matcher = re.compile(r"^<\s\s\s\sPRIVATE From>\[\s*(?P<nickname>[^\]]+)\]\s(?P<message>.*)")
|
matcher = re.compile(r"^<\s\s\s\sPRIVATE From>\[\s*(?P<nickname>[^\]]+)\]\s(?P<message>.*)")
|
||||||
@ -146,6 +160,7 @@ class ChatServerDisconnect(ChatLog):
|
|||||||
return '[disconnected]'
|
return '[disconnected]'
|
||||||
|
|
||||||
CHAT_LOGS = [
|
CHAT_LOGS = [
|
||||||
|
SystemMessage,
|
||||||
PrivateMessageReceived,
|
PrivateMessageReceived,
|
||||||
PrivateMessageSent,
|
PrivateMessageSent,
|
||||||
ChatMessage, # private messages need to be before chatmessage.
|
ChatMessage, # private messages need to be before chatmessage.
|
||||||
|
@ -39,6 +39,7 @@ class CombatLog(Log):
|
|||||||
|
|
||||||
def __init__(self, values=None):
|
def __init__(self, values=None):
|
||||||
self.values = values or {}
|
self.values = values or {}
|
||||||
|
self.reviewed = False
|
||||||
|
|
||||||
def unpack(self, force=False):
|
def unpack(self, force=False):
|
||||||
if self.reviewed and not force:
|
if self.reviewed and not force:
|
||||||
|
@ -58,6 +58,7 @@ class GameLog(Log):
|
|||||||
|
|
||||||
def __init__(self, values=None):
|
def __init__(self, values=None):
|
||||||
self.values = values
|
self.values = values
|
||||||
|
self.reviewed = False
|
||||||
|
|
||||||
def unpack(self, force=False):
|
def unpack(self, force=False):
|
||||||
if self.reviewed and not force:
|
if self.reviewed and not force:
|
||||||
|
@ -117,6 +117,11 @@ class LogFileSession(LogSession):
|
|||||||
self.game_log.set_data(z.read(filename))
|
self.game_log.set_data(z.read(filename))
|
||||||
self.game_log.parse()
|
self.game_log.parse()
|
||||||
self.files_parsed.append('game.log')
|
self.files_parsed.append('game.log')
|
||||||
|
elif fn == 'chat.log' and (not files or fn in files) and not 'chat.log' in self.files_parsed:
|
||||||
|
self.chat_log = ChatLogFile(fn)
|
||||||
|
self.chat_log.set_data(z.read(filename))
|
||||||
|
self.chat_log.parse()
|
||||||
|
self.files_parsed.append('chat.log')
|
||||||
except:
|
except:
|
||||||
self._error = True
|
self._error = True
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user