/offlineimap/head: changeset 217
-d now takes a parameter to specify what kind of debugging to do. imaplib now does debugging through the UI system. UIBase now has a debugging process.
This commit is contained in:
@ -22,6 +22,7 @@ Public functions: Internaldate2tuple
|
||||
__version__ = "2.52"
|
||||
|
||||
import binascii, re, socket, time, random, sys, os
|
||||
import __main__
|
||||
|
||||
__all__ = ["IMAP4", "Internaldate2tuple",
|
||||
"Int2AP", "ParseFlags", "Time2Internaldate"]
|
||||
@ -987,8 +988,7 @@ class IMAP4:
|
||||
if secs is None:
|
||||
secs = time.time()
|
||||
tm = time.strftime('%M:%S', time.localtime(secs))
|
||||
sys.stderr.write(' %s.%02d %s\n' % (tm, (secs*100)%100, s))
|
||||
sys.stderr.flush()
|
||||
__main__.ui.debug('imap', ' %s.%02d %s' % (tm, (secs*100)%100, s))
|
||||
|
||||
def _dump_ur(self, dict):
|
||||
# Dump untagged responses (in `dict').
|
||||
|
@ -58,7 +58,7 @@ class MaildirRepository(BaseRepository):
|
||||
# makedirs will fail because the higher-up dir already exists.
|
||||
# So, check to see if this is indeed the case.
|
||||
|
||||
if os.path.isdir(foldername):
|
||||
if self.getsep() == '/' and os.path.isdir(foldername):
|
||||
# Already exists. Sanity-check that it's not a Maildir.
|
||||
for subdir in ['cur', 'new', 'tmp']:
|
||||
assert not os.path.isdir(os.path.join(foldername, subdir)), \
|
||||
|
@ -23,8 +23,7 @@ from threading import *
|
||||
|
||||
class TTYUI(UIBase):
|
||||
def __init__(s, config, verbose = 0):
|
||||
s.config = config
|
||||
s.verbose = verbose
|
||||
UIBase.__init__(s, config, verbose)
|
||||
s.iswaiting = 0
|
||||
|
||||
def isusable(s):
|
||||
|
@ -21,10 +21,14 @@ import offlineimap.version
|
||||
import re, time, sys, traceback
|
||||
from StringIO import StringIO
|
||||
|
||||
debugtypes = {'imap': 'IMAP protocol debugging',
|
||||
'maildir': 'Maildir repository debugging'}
|
||||
|
||||
class UIBase:
|
||||
def __init__(s, config, verbose = 0):
|
||||
s.verbose = verbose
|
||||
s.config = config
|
||||
s.debuglist = []
|
||||
|
||||
################################################## UTILS
|
||||
def _msg(s, msg):
|
||||
@ -34,6 +38,26 @@ class UIBase:
|
||||
def warn(s, msg):
|
||||
s._msg("WARNING: " + msg)
|
||||
|
||||
def debug(s, debugtype, msg):
|
||||
if debugtype in s.debuglist:
|
||||
s._msg("DEBUG[%s]: %s" % (debugtype, msg))
|
||||
|
||||
def add_debug(s, debugtype):
|
||||
global debugtypes
|
||||
if debugtype in debugtypes:
|
||||
if not debugtype in s.debuglist:
|
||||
s.debuglist.append(debugtype)
|
||||
s.debugging(debugtype)
|
||||
else:
|
||||
s.invaliddebug(debugtype)
|
||||
|
||||
def debugging(s, debugtype):
|
||||
global debugtypes
|
||||
s._msg("Now debugging for %s: %s" % (debugtype, debugtypes[debugtype]))
|
||||
|
||||
def invaliddebug(s, debugtype):
|
||||
s.warn("Invalid debug type: %s" % debugtype)
|
||||
|
||||
def getnicename(s, object):
|
||||
prelimname = str(object.__class__).split('.')[-1]
|
||||
# Strip off extra stuff.
|
||||
|
Reference in New Issue
Block a user