From 89d038e93d32ff63526335aed72859099641edcd Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Thu, 29 Nov 2018 09:30:51 -0500 Subject: [PATCH] Added a try block around imap login --- aprsd/main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/aprsd/main.py b/aprsd/main.py index bd59198..14cca1d 100644 --- a/aprsd/main.py +++ b/aprsd/main.py @@ -214,8 +214,13 @@ def check_email_thread(): (CONFIG['imap']['host'], CONFIG['imap']['login'])) - server = IMAPClient(CONFIG['imap']['host'], use_uid=True) - server.login(CONFIG['imap']['login'], CONFIG['imap']['password']) + try: + server = IMAPClient(CONFIG['imap']['host'], use_uid=True, timeout=5) + server.login(CONFIG['imap']['login'], CONFIG['imap']['password']) + except Exception: + LOG.exception("Failed to login with IMAP server") + return + # select_info = server.select_folder('INBOX') messages = server.search(['SINCE', today]) @@ -460,12 +465,14 @@ def main(args=args): check_email_thread() # start email reader thread + LOG.info("Start main loop") while True: line = "" try: for char in tn.read_until("\n",100): line = line + char line = line.replace('\n', '') + print("ASS LINE %s" % line) LOG.info(line) searchstring = '::' + user # is aprs message to us, not beacon, status, etc