all latent changes, undisclosed and without warranty.
This commit is contained in:
@@ -92,11 +92,14 @@ class WarningLog(Log):
|
||||
# Individual logs.
|
||||
|
||||
class SteamInitialization(GameLog):
|
||||
matcher = []
|
||||
matcher = [
|
||||
re.compile(r"^Steam\sinitialized\sappId\s(?P<steam_app_id>\d+),\suserSteamID\s(?P<steam_id_universe>\d+)\|(?P<steam_id_type>\d+)\|(?P<steam_id_account_hex>\w+),\suserName\s'(?P<steam_username>[^']+)'"),
|
||||
]
|
||||
|
||||
class MasterServerSession(GameLog):
|
||||
matcher = [
|
||||
re.compile(r"^MasterServerSession\:\sconnect\sto\sdedicated\sserver(?:,\s|session\s(?P<session_id>\d+)|at addr (?P<addr>\d+\.\d+\.\d+\.\d+)\|(?P<port>\d+))+"),
|
||||
re.compile(r"^MasterServerSession\:\sconnect\sto\sdedicated\sserver(?:,\s|session\s(?P<session_id>\d+)|at addr (?P<addr>\d+\.\d+\.\d+\.\d+)\|(?P<port>\d+))+"),
|
||||
re.compile(r"^MasterServerSession:\sconnect\sto\sZoneInstance,\ssession\s(?P<session_id>\d+),\sat\saddr\s(?P<addr>\d+\.\d+\.\d+\.\d+)\|(?P<port>\d+),\szoneId\s(?P<zone_id>\d+)"),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
data by setting the LogFile<instance>._data yourself.
|
||||
"""
|
||||
import re
|
||||
from .base import Log
|
||||
RE_SCLOG = r'^(?P<hh>\d{2,2})\:(?P<mm>\d{2,2})\:(?P<ss>\d{2,2})\.(?P<ns>\d{3,3})\s(?P<logtype>\s*[^\|\s]+\s*|\s+)\|\s(?P<log>.*)'
|
||||
R_SCLOG = re.compile(RE_SCLOG)
|
||||
|
||||
@@ -33,6 +34,15 @@ class LogFile(object):
|
||||
|
||||
def _unset_data(self):
|
||||
self._data = None
|
||||
|
||||
def filter(self, klasses):
|
||||
ret = []
|
||||
for line in self.lines:
|
||||
for k in klasses:
|
||||
if isinstance(line, k):
|
||||
ret.append(line)
|
||||
break
|
||||
return ret
|
||||
|
||||
def parse(self):
|
||||
# parse _data if we still have no lines.
|
||||
@@ -83,4 +93,18 @@ class LogFile(object):
|
||||
# line is a dict.
|
||||
# try to find a class that is responsible for this log.
|
||||
return line
|
||||
|
||||
def clean(self):
|
||||
# cleans the logs by removing all non parsed packets.
|
||||
lines = []
|
||||
for l in self.lines:
|
||||
if isinstance(l, Log):
|
||||
if l.unpack():
|
||||
if not getattr(l, 'trash', False):
|
||||
lines.append(l)
|
||||
else:
|
||||
print type(l)
|
||||
print l
|
||||
self.lines = lines
|
||||
self._unset_data()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ class LogSession(object):
|
||||
''' if directory is a file, it will be handled as a compressed folder '''
|
||||
self.battles = []
|
||||
self.user = None
|
||||
self.files_parsed = []
|
||||
|
||||
# various logfiles used.
|
||||
self.combat_log = None
|
||||
@@ -27,6 +28,15 @@ class LogSession(object):
|
||||
self.idstr = None # id string to identify this log instance.
|
||||
self._error = False
|
||||
|
||||
def clean(self):
|
||||
if self.combat_log:
|
||||
self.combat_log.clean()
|
||||
if self.game_log:
|
||||
self.game_log.clean()
|
||||
if self.chat_log:
|
||||
self.chat_log.clean()
|
||||
|
||||
|
||||
def validate(self, contents=False):
|
||||
"""
|
||||
- validates if the logfiles are within this package.
|
||||
@@ -56,14 +66,18 @@ class LogSession(object):
|
||||
if self._zip_source:
|
||||
self._unzip_logs(files)
|
||||
else:
|
||||
if 'combat.log' in files:
|
||||
if files is None:
|
||||
files = self.VALID_FILES
|
||||
if 'combat.log' in files and not 'combat.log' in self.files_parsed:
|
||||
self.combat_log = CombatLogFile(os.path.join(self.directory, 'combat.log'))
|
||||
self.combat_log.read()
|
||||
self.combat_log.parse()
|
||||
if 'game.log' in files:
|
||||
self.files_parsed.append('combat.log')
|
||||
if 'game.log' in files and not 'game.log' in self.files_parsed:
|
||||
self.game_log = GameLogFile(os.path.join(self.directory, 'game.log'))
|
||||
self.game_log.read()
|
||||
self.game_log.parse()
|
||||
self.files_parsed.append('game.log')
|
||||
|
||||
def determine_owner(self):
|
||||
''' determines the user in the parsed gamelog '''
|
||||
@@ -80,12 +94,16 @@ class LogSession(object):
|
||||
fn = os.path.split(filename)[1] or ''
|
||||
fn = fn.lower()
|
||||
if fn:
|
||||
if fn == 'combat.log' and (not files or fn in files):
|
||||
if fn == 'combat.log' and (not files or fn in files) and not 'combat.log' in self.files_parsed:
|
||||
self.combat_log = CombatLogFile(fn)
|
||||
self.combat_log.set_data(z.read(filename))
|
||||
elif fn == 'game.log' and (not files or fn in files):
|
||||
self.combat_log.parse()
|
||||
self.files_parsed.append('combat.log')
|
||||
elif fn == 'game.log' and (not files or fn in files) and not 'game.log' in self.files_parsed:
|
||||
self.game_log = GameLogFile(fn)
|
||||
self.game_log.set_data(z.read(filename))
|
||||
self.game_log.parse()
|
||||
self.files_parsed.append('game.log')
|
||||
except:
|
||||
self._error = True
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user