aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--climl_imap_bridge.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/climl_imap_bridge.py b/climl_imap_bridge.py
index f1b2752..cfc527c 100644
--- a/climl_imap_bridge.py
+++ b/climl_imap_bridge.py
@@ -51,16 +51,18 @@ def connect_to_imap(conf, password):
connection.login(username=conf.get('imap.username'), password=password)
print('successfuly logged')
+ # TODO: replace shutdown by logouts when it will not timeout through ssl
try:
yield connection
- connection.logout()
- except (imapclient.AbortError, socket.error, socket.timeout,
+ #connection.logout()
+ except (connection.AbortError, socket.error, socket.timeout,
backports.ssl.SSLError, backports.ssl.CertificateError):
raise
else:
- connection.logout()
- #finally:
- # connection.shutdown()
+ pass
+ #connection.logout()
+ finally:
+ connection.shutdown()
def main():
confpath = os.path.expanduser('~/temp/conf.cfg')
@@ -74,12 +76,17 @@ def main():
#connection = connect_to_imap(conf, password)
with connect_to_imap(conf, password) as connection:
+ print('selecting folder')
+ connection.select_folder(conf.get('imap.mailbox'))
print('entering idle mode')
connection.idle()
print('waiting for an event')
- result = connection.idle_check(timeout=10)
- print('result:', result)
-
+ while True:
+ try:
+ result = connection.idle_check(timeout=10)
+ except KeyboardInterrupt:
+ break
+ print('result:', result)
print('end of connection')