From 042c669be17aff79e393811ed7d6c18c1a85d286 Mon Sep 17 00:00:00 2001 From: Andreas Wachowski Date: Sun, 13 Jun 2021 06:50:19 +0200 Subject: [PATCH] fix(log): Ensure tools/log paths are constructed portably On Linux, the backslash in "tools\log\" was not interpreted as path separator, so screenshots etc. ended up in the project's root directory, named "tools\log\". Now they are named "" and stored in the log-directory under tools. --- tools/its.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/its.py b/tools/its.py index 5fe9a20e..089916d0 100644 --- a/tools/its.py +++ b/tools/its.py @@ -399,7 +399,7 @@ def driver_get_cookies(self, driver, url, manual): def driver_termin_buchen(self, driver, reservierung): timestamp = time.strftime("%Y%m%d-%H%M%S") - filepath = os.path.join(self.PATH, "tools\\log\\") + filepath = os.path.join(self.PATH, "tools", "log") try: self.driver_enter_code( @@ -418,7 +418,7 @@ def driver_termin_buchen(self, driver, reservierung): except: self.log.error("Termine können nicht gesucht werden") try: - driver.save_screenshot(filepath + "errorterminsuche" + timestamp + ".png") + driver.save_screenshot(os.path.join(filepath, "errorterminsuche" + timestamp + ".png")) except: self.log.error("Screenshot konnte nicht gespeichert werden") pass @@ -435,10 +435,10 @@ def driver_termin_buchen(self, driver, reservierung): except: self.log.error("Termine können nicht ausgewählt werden") try: - with open(filepath + "errorterminauswahl" + timestamp + ".html", 'w', + with open(os.path.join(filepath, "errorterminauswahl" + timestamp + ".html"), 'w', encoding='utf-8') as file: file.write(str(driver.page_source)) - driver.save_screenshot(filepath + "errorterminauswahl" + timestamp + ".png") + driver.save_screenshot(os.path.join(filepath, "errorterminauswahl" + timestamp + ".png")) except: self.log.error("HTML und Screenshot konnten nicht gespeichert werden") pass @@ -524,7 +524,7 @@ def driver_termin_buchen(self, driver, reservierung): except: self.log.error("Kontaktdaten können nicht eingegeben werden") try: - driver.save_screenshot(filepath + "errordateneingeben" + timestamp + ".png") + driver.save_screenshot(os.path.join(filepath, "errordateneingeben" + timestamp + ".png")) except: self.log.error("Screenshot konnte nicht gespeichert werden") pass