-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.
+offlineimap (3.2.3) unstable; urgency=low
+
+ * -d now takes a parameter: imap or maildir (or both) to specify
+ what type of debugging to do.
+
+ -- John Goerzen <jgoerzen@complete.org> Thu, 8 Aug 2002 10:02:36 -0500
+
offlineimap (3.2.2) unstable; urgency=low
* Updated manual to show new Gray color.
]
.\".br
[
-.BI \-d
+.BI \-d \ debugtype[,debugtype...]
]
[
.BI \-o
Specifies a configuration file to use in lieu of the default,
.I ~/.offlineimaprc.
.TP
-.BI \-d
-Enables IMAP protocol stream and parsing debugging. This is useful if
+.BI \-d \ debugtype[,debugtype...]
+Enables debugging for OfflineIMAP. This is useful if
you are trying to track down a malfunction or figure out what is going
on under the hood. I suggest that you use this with
.BI \-1
-in order to make the results more sensible. Note that this output
-will contain full IMAP protocol in plain text, including passwords, so
-take care to remove that from the debugging output before sending it
-to anyone else.
+in order to make the results more sensible.
+.IP
+-d now requires one or more debugtypes, separated by commas. These
+define what exactly will be debugged, and so far include two options:
+.B imap
+and
+.B maildir.
+The
+.B imap
+option will enable IMAP protocol stream and parsing debugging. Note
+that the output may contain passwords, so take care to remove that
+from the debugging output before sending it to anyone else. The
+.B maildir
+option will enable debugging for certain Maildir operations.
.TP
.B \-o
Run only once, ignoring any autorefresh setting in the config file.
from offlineimap import imaplib, imaputil, imapserver, repository, folder, mbnames, threadutil, version
from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
+from offlineimap.ui import UIBase
import re, os, os.path, offlineimap, sys
from ConfigParser import ConfigParser
from threading import *
sys.stdout.write(version.cmdhelp + "\n")
sys.exit(0)
-for optlist in getopt(sys.argv[1:], 'P:1oa:c:du:h')[0]:
+for optlist in getopt(sys.argv[1:], 'P:1oa:c:d:u:h')[0]:
options[optlist[0]] = optlist[1]
-if '-d' in options:
- imaplib.Debug = 5
if '-h' in options:
sys.stdout.write(version.cmdhelp)
sys.stdout.write("\n")
ui = offlineimap.ui.detector.findUI(config)
ui.init_banner()
+if '-d' in options:
+ for debugtype in options['-d'].split(','):
+ ui.add_debug(debugtype.strip())
+ if debugtype == 'imap':
+ imaplib.Debug = 5
+
if '-o' in options and config.has_option("general", "autorefresh"):
config.remove_option("general", "autorefresh")
__version__ = "2.52"
import binascii, re, socket, time, random, sys, os
+import __main__
__all__ = ["IMAP4", "Internaldate2tuple",
"Int2AP", "ParseFlags", "Time2Internaldate"]
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').
# 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)), \
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):
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):
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.