diff --git a/offlineimap/head/offlineimap.conf b/offlineimap/head/offlineimap.conf index b54b243..d26cd12 100644 --- a/offlineimap/head/offlineimap.conf +++ b/offlineimap/head/offlineimap.conf @@ -54,7 +54,8 @@ maxsyncaccounts = 1 # fails, the second, and so forth. # # The pre-defined options are: -# Tk.TkUI -- A graphical interface +# Tk.Blinkenlights -- A graphical interface, shows LEDs and a single log +# Tk.VerboseUI -- A graphical interface, shows logs per thread # TTY.TTYUI -- a text-based (terminal) interface # Noninteractive.Basic -- Noninteractive interface suitable for cronning # Noninteractive.Quiet -- Noninteractive interface, generates no output @@ -62,7 +63,7 @@ maxsyncaccounts = 1 # # You can override this with a command-line option -u. -ui = Tk.TkUI, TTY.TTYUI +ui = Tk.Blinkenlights, Tk.VerboseUI, TTY.TTYUI, Noninteractive.Basic ################################################## @@ -87,6 +88,21 @@ peritem = "+%(accountname)s/%(foldername)s" sep = " " footer = "\n" +################################################## +# Blinkenlights configuration +################################################## + +[ui.Tk.Blinkenlights] + +# Specifies the default number of lines in the log. + +loglines = 5 + +# If true, says that the log should be enabled by default. +# Otherwise, you have to click "Show Log" to enable the log. + +showlog = false + ################################################## # Accounts ################################################## diff --git a/offlineimap/head/offlineimap.py b/offlineimap/head/offlineimap.py index b5ca253..5e76645 100644 --- a/offlineimap/head/offlineimap.py +++ b/offlineimap/head/offlineimap.py @@ -60,7 +60,7 @@ if not os.path.exists(configfilename): config.read(configfilename) if '-u' in options: - ui = offlineimap.ui.detector.getUImod(options['-u'])() + ui = offlineimap.ui.detector.getUImod(options['-u'])(config) else: ui = offlineimap.ui.detector.findUI(config) ui.init_banner() @@ -94,6 +94,8 @@ else: # asking for passwords simultaneously. for account in accounts: + if '.' in account: + raise ValueError, "Account '%s' contains a dot; dots are not allowed in account names." if config.has_option(account, "preauthtunnel"): tunnels[account] = config.get(account, "preauthtunnel") elif config.has_option(account, "remotepass"): diff --git a/offlineimap/head/offlineimap/ui/Noninteractive.py b/offlineimap/head/offlineimap/ui/Noninteractive.py index 945e137..42e5f9e 100644 --- a/offlineimap/head/offlineimap/ui/Noninteractive.py +++ b/offlineimap/head/offlineimap/ui/Noninteractive.py @@ -40,5 +40,5 @@ class Basic(UIBase): return 0 class Quiet(Basic): - def __init__(s, verbose = -1): - Basic.__init__(s, verbose) + def __init__(s, config, verbose = -1): + Basic.__init__(s, config, verbose) diff --git a/offlineimap/head/offlineimap/ui/Tk.py b/offlineimap/head/offlineimap/ui/Tk.py index 9617387..b1b24d2 100644 --- a/offlineimap/head/offlineimap/ui/Tk.py +++ b/offlineimap/head/offlineimap/ui/Tk.py @@ -358,14 +358,16 @@ class Blinkenlights(VerboseUI): self.canvas = c c.pack(side = BOTTOM, expand = 1) widthmetric = tkFont.Font(family = 'Helvetica', size = 8).measure("0") + self.loglines = 5 + if s.config.has_option("ui.Tk.Blinkenlights", "loglines"): + self.loglines = s.config.getint("ui.Tk.Blinkenlights", "loglines") self.text = Text(self.top, bg = 'black', font = ("Helvetica", 8), bd = 0, highlightthickness = 0, setgrid = 0, - state = DISABLED, height = 5, wrap = NONE, + state = DISABLED, height = self.loglines, wrap = NONE, width = int(c.cget('width')) / widthmetric) self.textenabled = 0 self.tags = [] self.textlock = Lock() - self.loglines = 5 def gettf(s, newtype=LEDThreadFrame): return VerboseUI.gettf(s, newtype, s.canvas) @@ -383,6 +385,9 @@ class Blinkenlights(VerboseUI): s.menubar = menubar s.gettf().setcolor('red') s._msg(version.banner) + if s.config.has_option("ui.Tk.Blinkenlights", "showlog") and \ + s.config.getboolean("ui.Tk.Blinkenlights", "showlog"): + s._togglelog() def _largerlog(s): s.loglines += 1 diff --git a/offlineimap/head/offlineimap/ui/UIBase.py b/offlineimap/head/offlineimap/ui/UIBase.py index 3ee0777..8019195 100644 --- a/offlineimap/head/offlineimap/ui/UIBase.py +++ b/offlineimap/head/offlineimap/ui/UIBase.py @@ -22,8 +22,9 @@ import re, time, sys, traceback from StringIO import StringIO class UIBase: - def __init__(s, verbose = 0): + def __init__(s, config, verbose = 0): s.verbose = verbose + s.config = config ################################################## UTILS def _msg(s, msg): diff --git a/offlineimap/head/offlineimap/ui/detector.py b/offlineimap/head/offlineimap/ui/detector.py index 1458038..e75783f 100644 --- a/offlineimap/head/offlineimap/ui/detector.py +++ b/offlineimap/head/offlineimap/ui/detector.py @@ -27,7 +27,7 @@ def findUI(config): for uistr in uistrlist: uimod = getUImod(uistr) if uimod: - uiinstance = uimod() + uiinstance = uimod(config) if uiinstance.isusable(): return uiinstance sys.stderr.write("ERROR: No UIs were found usable!\n")