mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-20 18:47:39 +03:00
scripts: Add eddn-report-log-errors
This looks at gateway.log files for any 'ERROR' lines. The output should be any lines representing an error that hasn't yet been reported to the softwareName's developer. NB: Absolutely relies on the developer changing the softwareVersion after applying a fix.
This commit is contained in:
parent
f8c1ce7a3e
commit
1bb8a37c34
191
eddn-report-log-errors
Executable file
191
eddn-report-log-errors
Executable file
@ -0,0 +1,191 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim: wrapmargin=0 textwidth=0 smarttab expandtab tabstop=2 shiftwidth=2
|
||||
"""Produce a report on the provided EDDN Gateway log file's ERRORs."""
|
||||
|
||||
import argparse
|
||||
import re
|
||||
|
||||
|
||||
def parse_cl_args() -> str:
|
||||
"""
|
||||
Check command-line arguments for input file name.
|
||||
|
||||
:returns: str - input file name
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='eddn-report-log-errors',
|
||||
description='Process an EDDN Gateway log file and report on any ERROR lines found'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'inputfile',
|
||||
metavar='<input file name>',
|
||||
help='Name of an EDDN Gateway log file'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
return args.inputfile
|
||||
|
||||
|
||||
def process_file(input_file: str) -> None:
|
||||
print(f'Input file: {input_file}')
|
||||
|
||||
_RE_ERROR = re.compile(
|
||||
r'^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}[\.,][0-9]{3} - ERROR - Gateway:[0-9]+:'
|
||||
r' (?P<err_msg>.+)'
|
||||
r' \((?P<request_size>[0-9]+),'
|
||||
r' "(?P<uploader_id>[^"]*)",'
|
||||
r' "(?P<software_name>[^"]*)",'
|
||||
r' "(?P<software_version>[^"]*)",'
|
||||
r' "(?P<schema_ref>[^"]*)",'
|
||||
r' "(?P<journal_event>[^"]*)"\)'
|
||||
r' from (?P<sender_ip>.+)$'
|
||||
)
|
||||
# TODO: Make this handle gzipped files
|
||||
with open(input_file, 'r') as input:
|
||||
line = input.readline()
|
||||
while line:
|
||||
line = line.strip()
|
||||
matches = _RE_ERROR.search(line)
|
||||
if matches:
|
||||
# print(matches.group('err_msg'))
|
||||
# print(matches.group('request_size'))
|
||||
# print(matches.group('uploader_id'))
|
||||
# print(matches.group('software_name'))
|
||||
# print(matches.group('software_version'))
|
||||
# print(matches.group('schema_ref'))
|
||||
# print(matches.group('journal_event'))
|
||||
# print(matches.group('sender_ip'))
|
||||
# print('')
|
||||
|
||||
###################################################################
|
||||
# Issues we know about and HAVE already alerted their
|
||||
# developers to.
|
||||
###################################################################
|
||||
if matches.group('software_name') == 'EDDiscovery':
|
||||
# https://github.com/EDDiscovery/EDDiscovery/releases/latest
|
||||
if matches.group('software_version') == '12.1.7.0':
|
||||
if matches.group('schema_ref') in (
|
||||
'https://eddn.edcd.io/schemas/shipyard/2',
|
||||
'https://eddn.edcd.io/schemas/outfitting/2',
|
||||
):
|
||||
# Reported via Discord PM to Robby 2022-01-07
|
||||
if matches.group('err_msg') != 'Failed Validation "[<ValidationError: \'[] is too short\'>]"':
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
elif matches.group('software_name') == 'EDDLite':
|
||||
# https://github.com/EDDiscovery/EDDLite/releases/tag/latest
|
||||
if matches.group('software_version') == '2.0.0':
|
||||
if matches.group('schema_ref') in (
|
||||
'https://eddn.edcd.io/schemas/shipyard/2',
|
||||
'https://eddn.edcd.io/schemas/outfitting/2',
|
||||
):
|
||||
# Reported via Discord PM to Robby 2022-01-07
|
||||
if matches.group('err_msg') != 'Failed Validation "[<ValidationError: \'[] is too short\'>]"':
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
elif matches.group('software_name') == 'EDDI':
|
||||
# https://github.com/EDCD/EDDI/releases/latest
|
||||
if matches.group('software_version') == '4.0.1':
|
||||
print(line)
|
||||
|
||||
elif matches.group('software_name') == 'E:D Market Connector [Windows]':
|
||||
# https://github.com/EDCD/EDMarketConnector/releases/latest
|
||||
if matches.group('software_version') == '5.2.4':
|
||||
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/codexentry/1':
|
||||
# <https://github.com/EDCD/EDMarketConnector/issues/1393>
|
||||
if matches.group('err_msg') != 'Failed Validation "[<ValidationError: "\'\' is too short">]"':
|
||||
print(matches.group('err_msg'))
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
elif matches.group('software_name') == 'Elite G19s Companion App':
|
||||
# <https://edcodex.info/?m=tools&entry=212>
|
||||
if matches.group('software_version') == '3.7.7888.21039':
|
||||
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/commodity/3':
|
||||
# Reported via Frontier forums: <https://forums.frontier.co.uk/threads/elite-g19s-companion-app-with-simulated-space-traffic-control.226782/post-9690204>
|
||||
if matches.group('err_msg') != 'Failed Validation "[<ValidationError: "Additional properties are not allowed (\'Proportion\', \'Name\' were unexpected)">]"':
|
||||
print(matches.group('err_msg'))
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
elif matches.group('software_name') == 'EDSM':
|
||||
# It's in-browser, no public source/releases
|
||||
if matches.group('software_version') == '1.0.1':
|
||||
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/journal/1':
|
||||
if matches.group('journal_event') == 'Scan':
|
||||
# <https://github.com/EDSM-NET/FrontEnd/issues/466>
|
||||
if not matches.group('err_msg').startswith(
|
||||
'Failed Validation "[<ValidationError: "{\'type\': [\'array\', \'boolean\', \'integer\', \'number\', \'null\', \'object\', \'string\']} is not allowed for '
|
||||
):
|
||||
print(matches.group('err_msg'))
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
elif matches.group('software_name') == 'EDSM - Console':
|
||||
# It's in-browser, no public source/releases
|
||||
if matches.group('software_version') == '1.0':
|
||||
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/journal/1':
|
||||
if matches.group('journal_event') == 'Scan':
|
||||
# <https://github.com/EDSM-NET/FrontEnd/issues/466>
|
||||
if not matches.group('err_msg').startswith(
|
||||
'Failed Validation "[<ValidationError: "{\'type\': [\'array\', \'boolean\', \'integer\', \'number\', \'null\', \'object\', \'string\']} is not allowed for '
|
||||
):
|
||||
print(matches.group('err_msg'))
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
elif matches.group('software_name') == 'EDAOS':
|
||||
# Apparently a Barry Carylon project, but no home page ?
|
||||
if matches.group('software_version') == '1.2.3':
|
||||
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/journal/1':
|
||||
if matches.group('journal_event') == 'Docked':
|
||||
# <https://discord.com/channels/164411426939600896/205369618284544000/929102478954340372>
|
||||
if not matches.group('err_msg').startswith(
|
||||
'Failed Validation "[<ValidationError: "{\'type\': [\'array\', \'boolean\', \'integer\', \'number\', \'null\', \'object\', \'string\']} is not allowed for '
|
||||
):
|
||||
print(matches.group('err_msg'))
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(line)
|
||||
|
||||
###################################################################
|
||||
# Issues we know about, but haven't yet alerted developers to
|
||||
###################################################################
|
||||
###################################################################
|
||||
else:
|
||||
print(line)
|
||||
|
||||
line = input.readline()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
input_file = parse_cl_args()
|
||||
|
||||
process_file(input_file)
|
Loading…
x
Reference in New Issue
Block a user