Ticket #16376: python-managesieve-0.3-darkness.patch
File python-managesieve-0.3-darkness.patch, 1.8 KB (added by gboyce@…, 16 years ago) |
---|
-
managesieve.py
old new 9 9 Ulrich Eck <ueck@net-labs.de> April 2001 10 10 """ 11 11 12 import binascii, re, socket, time, random, sys 12 import binascii, re, socket, time, random, sys, base64 13 13 14 14 __all__ = [ 'MANAGESIEVE', 'SIEVE_PORT', 'OK', 'NO', 'BYE', 'Debug'] 15 15 16 from imaplib import _log, _mesg 16 # XXX darky -- these are now in an IMAP4 class, and I don't think we 17 # should be using them. 18 #from imaplib import _log, _mesg 19 20 import logging 21 log = logging.getLogger("managesieve") 22 def _log(message): 23 log.debug(message) 24 _mesg = _log 17 25 18 26 Debug = 0 19 27 CRLF = '\r\n' … … 135 143 136 144 137 145 def _parse_capabilities(self, lines): 146 # XXX darky: seeing the STARTTLS cap makes managesieve barf 147 # because 'data' (in the below unpack) has nothing to unpack. 148 # Fix up lines for this. 149 for pair in lines: 150 if len(pair) == 1: 151 pair.append("") 152 assert len(pair) == 2 138 153 for typ, data in lines: 139 154 if __debug__: 140 155 if self.debug >= 3: … … 363 378 """ Login to the Sieve server using mechanism LOGIN. """ 364 379 return self.authenticate('LOGIN', user, password) 365 380 381 def auth_plain(self, auth, user, password): 382 authenticationData = "%s\0%s\0%s" % (auth, user, password) 383 authenticationData = base64.encodestring(authenticationData) 384 authenticationData = authenticationData.replace("\n", "") 385 typ, data = self._command("AUTHENTICATE", sieve_name("PLAIN"), 386 '"%s"' % (authenticationData,)) 387 if typ == 'OK': 388 self.state = 'AUTH' 389 return typ 366 390 367 391 def logout(self): 368 392 """Terminate connection to server."""