/offlineimap/head: changeset 480

Fixed the -l option
This commit is contained in:
jgoerzen 2003-06-02 20:52:33 +01:00
parent 332d07b4b0
commit d9c353b67a
2 changed files with 19 additions and 7 deletions

View File

@ -71,9 +71,13 @@ def startup(versionno):
config.read(configfilename)
ui = offlineimap.ui.detector.findUI(config, options.get('-u'))
ui.init_banner()
UIBase.setglobalui(ui)
if '-l' in options:
ui.setlogfd(open(options['-l'], 'wt'))
ui.init_banner()
if '-d' in options:
for debugtype in options['-d'].split(','):
ui.add_debug(debugtype.strip())
@ -82,9 +86,6 @@ def startup(versionno):
if debugtype == 'thread':
threading._VERBOSE = 1
if '-l' in options:
ui.setlogfd(open(options['-l'], 'wt'))
if '-o' in options:
# FIXME: maybe need a better
for section in accounts.getaccountlist(config):
@ -92,6 +93,9 @@ def startup(versionno):
lock(config, ui)
if '-l' in options:
sys.stderr = ui.logfile
activeaccounts = config.get("general", "accounts")
if '-a' in options:
activeaccounts = options['-a']

View File

@ -54,10 +54,18 @@ class UIBase:
if s.logfile:
s.logfile.write("%s: %s\n" % (threading.currentThread().getName(),
msg))
return s.logfile
return 1
return 0
def setlogfd(s, logfd):
s.logfile = logfd
logfd.write("This is %s %s %s\n" % \
(offlineimap.version.productname,
offlineimap.version.versionstr,
offlineimap.version.revstr))
logfd.write("Python: %s\n" % sys.version)
logfd.write("Platform: %s\n" % sys.platform)
logfd.write("Args: %s\n" % sys.argv)
def _display(s, msg):
"""Display a message."""
@ -100,8 +108,8 @@ class UIBase:
while len(s.debugmessages[thisthread]) > s.debugmsglen:
s.debugmessages[thisthread] = s.debugmessages[thisthread][1:]
if not s._log("DEBUG[%s]: %s"):
if debugtype in s.debuglist:
if debugtype in s.debuglist:
if not s._log("DEBUG[%s]: %s" % (debugtype, msg)):
s._display("DEBUG[%s]: %s" % (debugtype, msg))
def add_debug(s, debugtype):