|
@@ -149,19 +149,25 @@ class c11_export:
|
|
|
params.update(optional_params)
|
|
|
return params
|
|
|
|
|
|
- def filter_request_plan(req_plan: list[list[ReportRequest]], mail_csv: str):
|
|
|
- if not Path(mail_csv).exists():
|
|
|
+ def filter_request_plan(self, req_plan: list[list[ReportRequest]], mail_csv: str):
|
|
|
+ if not Path(mail_csv).exists() or not Path(mail_csv).is_file():
|
|
|
return req_plan
|
|
|
required_files = []
|
|
|
+ required_full_export = []
|
|
|
with open(Path(mail_csv), "r", encoding="latin-1") as rfh:
|
|
|
for row in rfh.readlines():
|
|
|
- filename, mailto = row.removesuffix("\r\n").split(";")
|
|
|
- if mailto == "":
|
|
|
- continue
|
|
|
- required_files.append(filename)
|
|
|
+ filename, mailto = row.split(";")
|
|
|
+ if "@" in mailto:
|
|
|
+ required_files.append(str(Path(self.cfg.cognos11.reportoutput_dir + '/' + filename).resolve()))
|
|
|
+ if "_Schichten." in filename:
|
|
|
+ filename2 = filename.replace("__Summe_und_Schichten", "__Summe").replace("__nur_Schichten", "__Summe")
|
|
|
+ required_full_export.append(str(Path(self.cfg.cognos11.reportoutput_dir + '/' + filename2).resolve()))
|
|
|
res = []
|
|
|
- for req_group in required_files:
|
|
|
- res.append([req for req in req_group if req.filename in required_files])
|
|
|
+ for req_group in req_plan:
|
|
|
+ if len(req_group) > 0 and str(Path(req_group[0].filename).resolve()) in required_full_export:
|
|
|
+ res.append(req_group)
|
|
|
+ else:
|
|
|
+ res.append([req for req in req_group if str(Path(req.filename).resolve()) in required_files])
|
|
|
return res
|
|
|
|
|
|
def execute_request_plan(self, req_plan: list[list[ReportRequest]]):
|
|
@@ -184,8 +190,11 @@ class c11_export:
|
|
|
if not save:
|
|
|
return
|
|
|
os.makedirs(os.path.dirname(report_request.filename), exist_ok=True)
|
|
|
- with open(report_request.filename, "wb") as f:
|
|
|
- f.write(content)
|
|
|
+ try:
|
|
|
+ with open(report_request.filename, "wb") as f:
|
|
|
+ f.write(content)
|
|
|
+ except PermissionError:
|
|
|
+ print("--> not accessible!")
|
|
|
|
|
|
def get_merge_group(self, req_plan: list[list[ReportRequest]]):
|
|
|
res = {}
|