/offlineimap/head: changeset 308
More progress at debugging. The curses blinkenlights is now working well, though it still has an occasional tendency to corrupt the light display with comments from the log. I suspect a locking problem -- need to be more strict with iolock I suspect. Updated various modules to register the threads' account names, etc.
This commit is contained in:
@@ -84,19 +84,23 @@ class CursesUtil:
|
||||
self.start()
|
||||
|
||||
class CursesAccountFrame:
|
||||
def __init__(s, master):
|
||||
def __init__(s, master, accountname):
|
||||
s.c = master
|
||||
s.children = []
|
||||
s.accountname = accountname
|
||||
|
||||
def setwindow(s, window):
|
||||
s.window = window
|
||||
location = 0
|
||||
acctstr = '%15.15s: ' % s.accountname
|
||||
s.window.addstr(0, 0, acctstr)
|
||||
s.location = len(acctstr)
|
||||
for child in s.children:
|
||||
child.update(window, 0, location)
|
||||
location += 1
|
||||
child.update(window, 0, s.location)
|
||||
s.location += 1
|
||||
|
||||
def getnewthreadframe(s):
|
||||
tf = CursesThreadFrame(s.c, s.window, 0, len(s.children))
|
||||
tf = CursesThreadFrame(s.c, s.window, 0, s.location)
|
||||
s.location += 1
|
||||
s.children.append(tf)
|
||||
return tf
|
||||
|
||||
@@ -120,21 +124,32 @@ class CursesThreadFrame:
|
||||
'orange': s.c.getpair(curses.COLOR_YELLOW, bg),
|
||||
'yellow': curses.A_BOLD | s.c.getpair(curses.COLOR_YELLOW, bg),
|
||||
'pink': curses.A_BOLD | s.c.getpair(curses.COLOR_RED, bg)}
|
||||
s.setcolor('gray')
|
||||
#s.setcolor('gray')
|
||||
s.setcolor('black')
|
||||
|
||||
def setcolor(self, color):
|
||||
self.color = self.colormap[color]
|
||||
self.display()
|
||||
|
||||
def display(self):
|
||||
self.window.addstr(self.y, self.x, '.', self.color)
|
||||
self.window.refresh()
|
||||
|
||||
def getcolor(self):
|
||||
return self.color
|
||||
|
||||
def update(self, window, y, x):
|
||||
self.window = window
|
||||
self.y = y
|
||||
self.x = x
|
||||
self.display()
|
||||
|
||||
def setthread(self, newthread):
|
||||
if newthread:
|
||||
self.setcolor('gray')
|
||||
else:
|
||||
self.setcolor('black')
|
||||
self.setcolor('black')
|
||||
#if newthread:
|
||||
# self.setcolor('gray')
|
||||
#else:
|
||||
# self.setcolor('black')
|
||||
|
||||
class InputHandler:
|
||||
def __init__(s, util):
|
||||
@@ -293,7 +308,7 @@ class Blinkenlights(BlinkenBase, UIBase):
|
||||
return s.af[accountname]
|
||||
|
||||
# New one.
|
||||
s.af[accountname] = CursesAccountFrame(s.c)
|
||||
s.af[accountname] = CursesAccountFrame(s.c, accountname)
|
||||
#s.iolock.acquire()
|
||||
s.c.reset()
|
||||
s.setupwindows(dolock = 0)
|
||||
|
@@ -55,8 +55,9 @@ class UIBase:
|
||||
"""Provides a hint to UIs about which account this particular
|
||||
thread is processing."""
|
||||
if s.threadaccounts.has_key(threading.currentThread()):
|
||||
raise ValueError, "Thread already registered (old %s, new %s)" % \
|
||||
(s.getthreadaccount(s), account)
|
||||
raise ValueError, "Thread %s already registered (old %s, new %s)" %\
|
||||
(threading.currentThread().getName(),
|
||||
s.getthreadaccount(s), account)
|
||||
s.threadaccounts[threading.currentThread()] = account
|
||||
|
||||
def unregisterthread(s, thr):
|
||||
@@ -69,7 +70,7 @@ class UIBase:
|
||||
thr = threading.currentThread()
|
||||
if s.threadaccounts.has_key(thr):
|
||||
return s.threadaccounts[thr]
|
||||
return None
|
||||
return '*Control'
|
||||
|
||||
def debug(s, debugtype, msg):
|
||||
thisthread = threading.currentThread()
|
||||
|
Reference in New Issue
Block a user