Added Debug for imaplib2

When I ported offlineimap from Python 2 to Python 3 I removed the Debug for
IMAP (imaplib2).
The reason was offlineimap was setting the Debug directly in imaplib2,
not using the proper way (using the IMAP4 argument). Because we are
removing the virtual_imaplib2, I removed this option.

I removed this line in offlineimap/init.py:303:

---8<---
 300        dtype = dtype.strip()
 301        self.ui.add_debug(dtype)
 302        if dtype.lower() == u'imap':
-303          imaplib.Debug = 5
 304
 305     if options.runonce:
 306         # Must kill the possible default option.
---8<---

With this patch, the debug level 5 is restored in imaplib if the user
set the -d ALL or -d imap in offlineimap.
This commit is contained in:
Rodolfo García Peñas (kix) 2020-11-08 21:30:22 +01:00
parent ff0b84ff2b
commit ca0a2651a3

View File

@ -515,6 +515,10 @@ class IMAPServer:
curThread = currentThread()
imapobj = None
imap_debug = 0
if 'imap' in self.ui.debuglist:
imap_debug = 5
if len(self.availableconnections): # One is available.
# Try to find one that previously belonged to this thread
# as an optimization. Start from the back since that's where
@ -547,6 +551,7 @@ class IMAPServer:
imapobj = imaplibutil.IMAP4_Tunnel(
self.tunnel,
timeout=socket.getdefaulttimeout(),
debug=imap_debug,
use_socket=self.proxied_socket,
)
success = True
@ -563,6 +568,7 @@ class IMAPServer:
ca_certs=self.sslcacertfile,
cert_verify_cb=self.__verifycert,
ssl_version=self.sslversion,
debug=imap_debug,
timeout=socket.getdefaulttimeout(),
fingerprint=self.fingerprint,
use_socket=self.proxied_socket,
@ -576,6 +582,7 @@ class IMAPServer:
self.hostname, self.port,
timeout=socket.getdefaulttimeout(),
use_socket=self.proxied_socket,
debug=imap_debug,
af=self.af,
)