|  | @@ -20,9 +20,7 @@ class PrepareLogfiles:
 | 
	
		
			
				|  |  |      def convert_logfile(self, sm: StatusMeldung):
 | 
	
		
			
				|  |  |          whitelist_str = sm.kunde_ref.whitelist if sm.kunde_ref is not None else ""
 | 
	
		
			
				|  |  |          whitelist = self.get_whitelist(whitelist_str)
 | 
	
		
			
				|  |  | -        fehlerbericht = dict(
 | 
	
		
			
				|  |  | -            [(f["Name"], f) for f in json.loads(sm.fehlerbericht_import)]
 | 
	
		
			
				|  |  | -        )
 | 
	
		
			
				|  |  | +        fehlerbericht = dict([(f["Name"], f) for f in json.loads(sm.fehlerbericht_import)])
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          for name, report in fehlerbericht.items():
 | 
	
		
			
				|  |  |              if ".bat" in name:
 | 
	
	
		
			
				|  | @@ -65,16 +63,9 @@ class PrepareLogfiles:
 | 
	
		
			
				|  |  |                  e = re.sub(r"Copyright ", "§", e)
 | 
	
		
			
				|  |  |                  loglevel_warn = [b for b in e.split("§") if "Status:" not in b]
 | 
	
		
			
				|  |  |                  loglevel_error = [b for b in loglevel_warn if "Fehler:" in b]
 | 
	
		
			
				|  |  | -                loglevel_combined = [
 | 
	
		
			
				|  |  | -                    "<b>" + b + "</b>" if "Fehler:" in b else b for b in loglevel_warn
 | 
	
		
			
				|  |  | -                ]
 | 
	
		
			
				|  |  | -                loglevel_combined[-1] = loglevel_combined[-1].replace(
 | 
	
		
			
				|  |  | -                    "DTSER_FAILURE", "<b>DTSER_FAILURE</b>"
 | 
	
		
			
				|  |  | -                )
 | 
	
		
			
				|  |  | -                if (
 | 
	
		
			
				|  |  | -                    len(loglevel_error) > 0
 | 
	
		
			
				|  |  | -                    or "DTSER_SUCCESS" not in loglevel_combined[-1]
 | 
	
		
			
				|  |  | -                ):
 | 
	
		
			
				|  |  | +                loglevel_combined = ["<b>" + b + "</b>" if "Fehler:" in b else b for b in loglevel_warn]
 | 
	
		
			
				|  |  | +                loglevel_combined[-1] = loglevel_combined[-1].replace("DTSER_FAILURE", "<b>DTSER_FAILURE</b>")
 | 
	
		
			
				|  |  | +                if len(loglevel_error) > 0 or "DTSER_SUCCESS" not in loglevel_combined[-1]:
 | 
	
		
			
				|  |  |                      report["ErrorLevel"] = 2
 | 
	
		
			
				|  |  |                      sm.anzahl += 1
 | 
	
		
			
				|  |  |                  report["Errors"][0] = "\n".join(loglevel_combined)
 | 
	
	
		
			
				|  | @@ -82,12 +73,8 @@ class PrepareLogfiles:
 | 
	
		
			
				|  |  |                  "Portal",
 | 
	
		
			
				|  |  |                  "Versand",
 | 
	
		
			
				|  |  |              ]:
 | 
	
		
			
				|  |  | -                report["Errors2"] = [
 | 
	
		
			
				|  |  | -                    e for e in report["Errors"] if self.in_whitelist(e, whitelist)
 | 
	
		
			
				|  |  | -                ]
 | 
	
		
			
				|  |  | -                report["Errors"] = [
 | 
	
		
			
				|  |  | -                    e for e in report["Errors"] if e not in report["Errors2"]
 | 
	
		
			
				|  |  | -                ]
 | 
	
		
			
				|  |  | +                report["Errors2"] = [e for e in report["Errors"] if self.in_whitelist(e, whitelist)]
 | 
	
		
			
				|  |  | +                report["Errors"] = [e for e in report["Errors"] if e not in report["Errors2"]]
 | 
	
		
			
				|  |  |                  if len(report["Errors"]) == 0:
 | 
	
		
			
				|  |  |                      report["ErrorLevel"] = 3
 | 
	
		
			
				|  |  |                      sm.anzahl -= 1
 | 
	
	
		
			
				|  | @@ -95,9 +82,7 @@ class PrepareLogfiles:
 | 
	
		
			
				|  |  |          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)
 | 
	
		
			
				|  |  | -        systeminfo_log = SysteminfoLog(
 | 
	
		
			
				|  |  | -            fehlerbericht.get("system.info", {"Errors": [""]})
 | 
	
		
			
				|  |  | -        )
 | 
	
		
			
				|  |  | +        SysteminfoLog(fehlerbericht.get("system.info", {"Errors": [""]}))
 | 
	
		
			
				|  |  |          # if systeminfo_log.ip_address == "0.0.0.0":
 | 
	
		
			
				|  |  |          # print(sm.kunde)
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -132,13 +117,13 @@ class PrepareLogfiles:
 | 
	
		
			
				|  |  |          return whitelist
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -def main():
 | 
	
		
			
				|  |  | +def prepare_logfiles():
 | 
	
		
			
				|  |  |      mi = PrepareLogfiles()
 | 
	
		
			
				|  |  |      mi.prepare_logfiles()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  if __name__ == "__main__":
 | 
	
		
			
				|  |  | -    main()
 | 
	
		
			
				|  |  | +    prepare_logfiles()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      # import cProfile
 | 
	
		
			
				|  |  |  
 |