Better error handling for parsing errors in MOSMessageLogs.
This commit is contained in:
parent
d0e00a02b2
commit
c88691e71c
@ -44,25 +44,33 @@ file_count = 0
|
||||
last_file = ""
|
||||
for file in files_to_parse:
|
||||
file_count += 1
|
||||
last_file = os.path.basename(file)
|
||||
tree = ET.parse(file)
|
||||
print("\n{} [{:d}/{:d}]: ".format(file, file_count, num_files), end="")
|
||||
try:
|
||||
tree = ET.parse(file)
|
||||
|
||||
root = tree.getroot()
|
||||
# Walk all <mosNotify...> objects
|
||||
for elem in root:
|
||||
# Skip everything which is not a mosObj message
|
||||
if elem.attrib.get("command") != "mosObj":
|
||||
continue
|
||||
root = tree.getroot()
|
||||
# Walk all <mosNotify...> objects
|
||||
for elem in root:
|
||||
# Skip everything which is not a mosObj message
|
||||
if elem.attrib.get("command") != "mosObj":
|
||||
continue
|
||||
|
||||
mos = elem.find("mos")
|
||||
objData = MosXml.parse_mos_xml(mos)
|
||||
if objData['isDeleted'] == 0:
|
||||
db.add_or_replace(objData)
|
||||
print(".", end="")
|
||||
else:
|
||||
db.mark_deleted(objData)
|
||||
print("x", end="")
|
||||
mos = elem.find("mos")
|
||||
objData = MosXml.parse_mos_xml(mos)
|
||||
if objData['isDeleted'] == 0:
|
||||
db.add_or_replace(objData)
|
||||
print(".", end="")
|
||||
else:
|
||||
db.mark_deleted(objData)
|
||||
print("x", end="")
|
||||
|
||||
last_file = os.path.basename(file)
|
||||
except ET.ParseError as e:
|
||||
print("ERROR parsing {}: {}".format(file, e), file=sys.stderr)
|
||||
break
|
||||
except:
|
||||
print("ERROR processing {}!".format(file), file=sys.stderr)
|
||||
break
|
||||
|
||||
db.finish()
|
||||
print("")
|
||||
|
Loading…
x
Reference in New Issue
Block a user