/offlineimap/head: changeset 183

Adding configuration information for Blinkenlights.
This commit is contained in:
jgoerzen 2002-07-24 23:20:42 +01:00
parent 11ca9ea196
commit 2a4b20e951
6 changed files with 33 additions and 9 deletions

View File

@ -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
##################################################

View File

@ -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"):

View File

@ -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)

View File

@ -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

View File

@ -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):

View File

@ -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")