From 636044ab522fd0e509dda351e951a0a6876f3c5c Mon Sep 17 00:00:00 2001 From: Stefano Marinelli Date: Mon, 23 Oct 2023 08:10:46 +0200 Subject: [PATCH] Fixed output --- NotiMail.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/NotiMail.py b/NotiMail.py index 31c9b8e..851d77e 100644 --- a/NotiMail.py +++ b/NotiMail.py @@ -287,7 +287,7 @@ class IMAPHandler: self.mail.select('inbox') except imaplib.IMAP4.error as e: print(f"Cannot connect: {str(e)}") - notifier.send_notification("Script Error", f"[{self.email_user}] Cannot connect: {str(e)}") + notifier.send_notification("Script Error", f"Cannot connect: {str(e)}") raise def idle(self): @@ -302,7 +302,7 @@ class IMAPHandler: if line: print(line.decode('utf-8')) if b'BYE' in line: - raise ConnectionAbortedError("[{self.email_user}] Received BYE from server. Trying to reconnect...") + raise ConnectionAbortedError("Received BYE from server. Trying to reconnect...") if b'EXISTS' in line: break self.mail.send(b'DONE\r\n') @@ -310,16 +310,16 @@ class IMAPHandler: except imaplib.IMAP4.abort as e: print(f"Connection closed by server: {str(e)}") logging.error(f"[{self.email_user}] Connection closed by server: {str(e)}") - notifier.send_notification("Script Error", f"[{self.email_user}] Connection closed by server: {str(e)}") - raise ConnectionAbortedError("[{self.email_user}] Connection lost. Trying to reconnect...") + notifier.send_notification("Script Error", f"Connection closed by server: {str(e)}") + raise ConnectionAbortedError("Connection lost. Trying to reconnect...") except socket.timeout: print("Socket timeout during IDLE, re-establishing connection...") logging.info(f"[{self.email_user}] Socket timeout during IDLE, re-establishing connection...") - raise ConnectionAbortedError("[{self.email_user}] Socket timeout. Trying to reconnect...") + raise ConnectionAbortedError("Socket timeout. Trying to reconnect...") except Exception as e: print(f"An error occurred: {str(e)}") logging.info(f"[{self.email_user}] An error occurred: {str(e)}") - notifier.send_notification("Script Error", f"[{self.email_user}] An error occurred: {str(e)}") + notifier.send_notification("Script Error", f"An error occurred: {str(e)}") raise finally: print("IDLE mode stopped.")