aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2015-12-24 16:58:44 +0100
committerVG <vg@devys.org>2015-12-24 16:58:44 +0100
commita373f47a7d0b329dc04698ee3345cb232c452479 (patch)
tree9dd0beabf486dd6b59c1f050a2278342231bfa77
parentde30c86c12246c0ac3bd5e5d40a58d1cafc63584 (diff)
downloadcliml-tests.tar.gz
climl-tests.tar.bz2
climl-tests.zip
Fix imap idle checking with remote servertests
- fix exception class - select a mailbox to check incomming emails for - make the bridge run continuously until stopped with siginterrupt
-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')