summaryrefslogtreecommitdiffstats
path: root/pykolab/imap/cyrus.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-07-06 18:24:09 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-07-06 18:24:09 +0100
commit6cc40d31ef0aab69b4d3868e277cfaddad226d9d (patch)
tree374d0e15d3c6a95b456dc5005f37c7de392f113c /pykolab/imap/cyrus.py
parent00ef2f73974fd25b437f43d4feb978edcdd741e7 (diff)
downloadpykolab-6cc40d31ef0aab69b4d3868e277cfaddad226d9d.tar.gz
On el5, urlparse returns a tuple
Diffstat (limited to 'pykolab/imap/cyrus.py')
-rw-r--r--pykolab/imap/cyrus.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py
index 050507d..a03ccbd 100644
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -50,20 +50,27 @@ class Cyrus(cyruslib.CYRUS):
"""
Initialize this class, but do not connect yet.
"""
+ port = None
+
result = urlparse(uri)
- # Complete the uri with the result to avoid cyruslib from bailing out.
- if not hasattr(result,'port'):
- if result.scheme == 'imap':
+ if hasattr(result, 'hostname'):
+ scheme = result.scheme
+ hostname = result.hostname
+ port = result.port
+ else:
+ scheme = uri.split(':')[0]
+ (hostname, port) = uri.split('/')[2].split(':')
+
+ if not port:
+ if scheme == 'imap':
port = 143
else:
port = 993
- else:
- port = result.port
- self.server = result.hostname
+ self.server = hostname
- self.uri = "%s://%s:%s" %(result.scheme,result.hostname,port)
+ self.uri = "%s://%s:%s" %(scheme,hostname,port)
cyruslib.CYRUS.__init__(self, self.uri)