|
@@ -8,11 +8,14 @@ import os
|
|
|
from sqlalchemy import create_engine, select
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
+# from datetime import date, timedelta
|
|
|
+
|
|
|
|
|
|
class PrepareLogfiles:
|
|
|
def prepare_logfiles(self):
|
|
|
with Session(create_engine(DSN)) as db_session:
|
|
|
query = select(StatusMeldung).where(StatusMeldung.fehlerbericht.is_(None))
|
|
|
+ # .where(StatusMeldung.datum.between(date.today() - timedelta(days=3), date.today()))
|
|
|
for sm in db_session.scalars(query):
|
|
|
self.convert_logfile(sm)
|
|
|
db_session.commit()
|
|
@@ -33,8 +36,10 @@ class PrepareLogfiles:
|
|
|
"!! SMTP-Konfiguration bitte anpassen !!",
|
|
|
"! SMTP-Konfiguration bitte anpassen !",
|
|
|
)
|
|
|
- e, err_count = re.subn(r"(!![^\n]*!!)", r"<b>\1</b>", e)
|
|
|
- e, err_count2 = re.subn(
|
|
|
+ err_count = [0] * 10
|
|
|
+
|
|
|
+ e, err_count[0] = re.subn(r"(!![^\n]*!!)", r"<b>\1</b>", e)
|
|
|
+ e, err_count[1] = re.subn(
|
|
|
r"\((\w{2}\d{4})\)( [^\r]*)",
|
|
|
r"<b><a href='/wiki/\1' target='_blank'>(\1)</a>\2</b>",
|
|
|
e,
|
|
@@ -46,14 +51,20 @@ class PrepareLogfiles:
|
|
|
e,
|
|
|
)
|
|
|
|
|
|
- err_count3 = 0
|
|
|
- e, err_count3 = re.subn(
|
|
|
+ e, err_count[2] = re.subn(
|
|
|
r"(Error \= \[Micro[^\r]*)",
|
|
|
r"<b>\1</b>",
|
|
|
e,
|
|
|
)
|
|
|
|
|
|
- if sum([err_count, err_count2, err_count3]) > 0:
|
|
|
+ e, err_count[3] = re.subn(r"(Der Befehl \".*\" ist entweder falsch geschrieben)", r"<b>\1</b>", e)
|
|
|
+
|
|
|
+ e, err_count[4] = re.subn(r"(FEHLER: .*: Source: Impromptu)", r"<b>\1</b>", e)
|
|
|
+ e, err_count[5] = re.subn(r"(Traceback)", r"<b>\1</b>", e)
|
|
|
+ e, err_count[6] = re.subn(r"(Fatal error: Uncaught exception)", r"<b>\1</b>", e)
|
|
|
+ e, err_count[7] = re.subn(r"(Failed to create COM object)", r"<b>\1</b>", e)
|
|
|
+
|
|
|
+ if sum(err_count) > 0:
|
|
|
report["ErrorLevel"] = 2
|
|
|
report["Errors"] = [e] + re.findall(r"<b>[^\n]*</b>", e)
|
|
|
sm.anzahl += 1
|
|
@@ -69,6 +80,10 @@ class PrepareLogfiles:
|
|
|
report["ErrorLevel"] = 2
|
|
|
sm.anzahl += 1
|
|
|
report["Errors"][0] = "\n".join(loglevel_combined)
|
|
|
+ elif report["Type"] == "Modell":
|
|
|
+ if len(report["Errors"]) > 0:
|
|
|
+ report["ErrorLevel"] = str(min([int(e["Level"]) for e in report["Errors"]]))
|
|
|
+
|
|
|
elif len(report["Errors"]) > 0 and report["Type"] in [
|
|
|
"Portal",
|
|
|
"Versand",
|
|
@@ -79,6 +94,7 @@ class PrepareLogfiles:
|
|
|
report["ErrorLevel"] = 3
|
|
|
sm.anzahl -= 1
|
|
|
|
|
|
+ sm.anzahl = max(0, sm.anzahl)
|
|
|
sm.fehlerbericht = json.dumps(list(fehlerbericht.values()), indent=2)
|
|
|
# self.export_log_files(sm, fehlerbericht)
|
|
|
# batch_log = [f for f in fehlerbericht if ".bat" in f["Name"]].pop(0)
|
|
@@ -91,6 +107,7 @@ class PrepareLogfiles:
|
|
|
[
|
|
|
e["Layer"] in whitelist["Layer"],
|
|
|
e["Report"] in whitelist["Report"],
|
|
|
+ e["Report"].lower().endswith("_graf"),
|
|
|
e["User"] in whitelist["User"],
|
|
|
]
|
|
|
)
|