/offlineimap/head: changeset 309
More progress with bug fixes and locking
This commit is contained in:
parent
d6b790a7da
commit
2b9c425091
@ -204,7 +204,7 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
|
|||||||
|
|
||||||
# Synchronize remote changes.
|
# Synchronize remote changes.
|
||||||
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
|
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
|
||||||
remotefolder.syncmessagesto(localfolder)
|
remotefolder.syncmessagesto(localfolder, [localfolder, statusfolder])
|
||||||
|
|
||||||
# Make sure the status folder is up-to-date.
|
# Make sure the status folder is up-to-date.
|
||||||
ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder)
|
ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder)
|
||||||
|
@ -90,7 +90,7 @@ class BlinkenBase:
|
|||||||
|
|
||||||
UIBase.threadExited(s, thread)
|
UIBase.threadExited(s, thread)
|
||||||
|
|
||||||
def gettf(s):
|
def gettf(s, lock = 1):
|
||||||
threadid = thread.get_ident()
|
threadid = thread.get_ident()
|
||||||
accountname = s.getthreadaccount()
|
accountname = s.getthreadaccount()
|
||||||
|
|
||||||
@ -108,9 +108,9 @@ class BlinkenBase:
|
|||||||
|
|
||||||
if len(s.availablethreadframes[accountname]):
|
if len(s.availablethreadframes[accountname]):
|
||||||
tf = s.availablethreadframes[accountname].pop(0)
|
tf = s.availablethreadframes[accountname].pop(0)
|
||||||
tf.setthread(currentThread())
|
tf.setthread(currentThread(), lock)
|
||||||
else:
|
else:
|
||||||
tf = s.getaccountframe().getnewthreadframe()
|
tf = s.getaccountframe().getnewthreadframe(lock)
|
||||||
s.threadframes[accountname][threadid] = tf
|
s.threadframes[accountname][threadid] = tf
|
||||||
return tf
|
return tf
|
||||||
|
|
||||||
|
@ -84,29 +84,31 @@ class CursesUtil:
|
|||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
class CursesAccountFrame:
|
class CursesAccountFrame:
|
||||||
def __init__(s, master, accountname):
|
def __init__(s, master, accountname, iolock):
|
||||||
|
s.iolock = iolock
|
||||||
s.c = master
|
s.c = master
|
||||||
s.children = []
|
s.children = []
|
||||||
s.accountname = accountname
|
s.accountname = accountname
|
||||||
|
|
||||||
def setwindow(s, window):
|
def setwindow(s, window, lock = 1):
|
||||||
s.window = window
|
s.window = window
|
||||||
acctstr = '%15.15s: ' % s.accountname
|
acctstr = '%15.15s: ' % s.accountname
|
||||||
s.window.addstr(0, 0, acctstr)
|
s.window.addstr(0, 0, acctstr)
|
||||||
s.location = len(acctstr)
|
s.location = len(acctstr)
|
||||||
for child in s.children:
|
for child in s.children:
|
||||||
child.update(window, 0, s.location)
|
child.update(window, 0, s.location, lock)
|
||||||
s.location += 1
|
s.location += 1
|
||||||
|
|
||||||
def getnewthreadframe(s):
|
def getnewthreadframe(s, lock = 1):
|
||||||
tf = CursesThreadFrame(s.c, s.window, 0, s.location)
|
tf = CursesThreadFrame(s.c, s.window, 0, s.location, s.iolock, lock)
|
||||||
s.location += 1
|
s.location += 1
|
||||||
s.children.append(tf)
|
s.children.append(tf)
|
||||||
return tf
|
return tf
|
||||||
|
|
||||||
class CursesThreadFrame:
|
class CursesThreadFrame:
|
||||||
def __init__(s, master, window, y, x):
|
def __init__(s, master, window, y, x, iolock, lock = 1):
|
||||||
"""master should be a CursesUtil object."""
|
"""master should be a CursesUtil object."""
|
||||||
|
s.iolock = iolock
|
||||||
s.c = master
|
s.c = master
|
||||||
s.window = window
|
s.window = window
|
||||||
s.x = x
|
s.x = x
|
||||||
@ -125,27 +127,33 @@ class CursesThreadFrame:
|
|||||||
'yellow': curses.A_BOLD | 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)}
|
'pink': curses.A_BOLD | s.c.getpair(curses.COLOR_RED, bg)}
|
||||||
#s.setcolor('gray')
|
#s.setcolor('gray')
|
||||||
s.setcolor('black')
|
s.setcolor('black', lock)
|
||||||
|
|
||||||
def setcolor(self, color):
|
def setcolor(self, color, lock = 1):
|
||||||
self.color = self.colormap[color]
|
self.color = self.colormap[color]
|
||||||
self.display()
|
self.display(lock)
|
||||||
|
|
||||||
def display(self):
|
def display(self, lock = 1):
|
||||||
|
if lock:
|
||||||
|
self.iolock.acquire()
|
||||||
|
try:
|
||||||
self.window.addstr(self.y, self.x, '.', self.color)
|
self.window.addstr(self.y, self.x, '.', self.color)
|
||||||
self.window.refresh()
|
self.window.refresh()
|
||||||
|
finally:
|
||||||
|
if lock:
|
||||||
|
self.iolock.release()
|
||||||
|
|
||||||
def getcolor(self):
|
def getcolor(self):
|
||||||
return self.color
|
return self.color
|
||||||
|
|
||||||
def update(self, window, y, x):
|
def update(self, window, y, x, lock = 1):
|
||||||
self.window = window
|
self.window = window
|
||||||
self.y = y
|
self.y = y
|
||||||
self.x = x
|
self.x = x
|
||||||
self.display()
|
self.display(lock)
|
||||||
|
|
||||||
def setthread(self, newthread):
|
def setthread(self, newthread, lock = 1):
|
||||||
self.setcolor('black')
|
self.setcolor('black', lock)
|
||||||
#if newthread:
|
#if newthread:
|
||||||
# self.setcolor('gray')
|
# self.setcolor('gray')
|
||||||
#else:
|
#else:
|
||||||
@ -232,9 +240,8 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
BlinkenBase.init_banner(s)
|
BlinkenBase.init_banner(s)
|
||||||
s.setupwindows(dolock = 0)
|
s.setupwindows(dolock = 0)
|
||||||
s.inputhandler = InputHandler(s.c)
|
s.inputhandler = InputHandler(s.c)
|
||||||
|
s.gettf().setcolor('red')
|
||||||
s._msg(version.banner)
|
s._msg(version.banner)
|
||||||
s._msg(str(dir(s.c.stdscr)))
|
|
||||||
s.inputhandler.set_bgchar(s.keypress)
|
s.inputhandler.set_bgchar(s.keypress)
|
||||||
|
|
||||||
def keypress(s, key):
|
def keypress(s, key):
|
||||||
@ -244,10 +251,10 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
s.inputhandler.input_acquire()
|
s.inputhandler.input_acquire()
|
||||||
s.iolock.acquire()
|
s.iolock.acquire()
|
||||||
try:
|
try:
|
||||||
s.gettf().setcolor('white')
|
s.gettf(lock = 0).setcolor('white', lock = 0)
|
||||||
s._addline_unlocked(" *** Input Required", s.gettf().getcolor())
|
s._addline_unlocked(" *** Input Required", s.gettf().getcolor())
|
||||||
s._addline_unlocked(" *** Please enter password for account %s: " % accountname,
|
s._addline_unlocked(" *** Please enter password for account %s: " % accountname,
|
||||||
s.gettf().getcolor())
|
s.gettf(lock = 0).getcolor())
|
||||||
s.logwindow.refresh()
|
s.logwindow.refresh()
|
||||||
password = s.logwindow.getstr()
|
password = s.logwindow.getstr()
|
||||||
finally:
|
finally:
|
||||||
@ -266,7 +273,6 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
s.logwindow.idlok(1)
|
s.logwindow.idlok(1)
|
||||||
s.logwindow.scrollok(1)
|
s.logwindow.scrollok(1)
|
||||||
s.setupwindow_drawlog()
|
s.setupwindow_drawlog()
|
||||||
|
|
||||||
accounts = s.af.keys()
|
accounts = s.af.keys()
|
||||||
accounts.sort()
|
accounts.sort()
|
||||||
accounts.reverse()
|
accounts.reverse()
|
||||||
@ -274,11 +280,10 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
pos = s.c.height - 1
|
pos = s.c.height - 1
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
accountwindow = curses.newwin(1, s.c.width, pos, 0)
|
accountwindow = curses.newwin(1, s.c.width, pos, 0)
|
||||||
s.af[account].setwindow(accountwindow)
|
s.af[account].setwindow(accountwindow, lock = 0)
|
||||||
pos -= 1
|
pos -= 1
|
||||||
|
|
||||||
curses.doupdate()
|
curses.doupdate()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if dolock:
|
if dolock:
|
||||||
s.iolock.release()
|
s.iolock.release()
|
||||||
@ -308,7 +313,7 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
return s.af[accountname]
|
return s.af[accountname]
|
||||||
|
|
||||||
# New one.
|
# New one.
|
||||||
s.af[accountname] = CursesAccountFrame(s.c, accountname)
|
s.af[accountname] = CursesAccountFrame(s.c, accountname, s.iolock)
|
||||||
#s.iolock.acquire()
|
#s.iolock.acquire()
|
||||||
s.c.reset()
|
s.c.reset()
|
||||||
s.setupwindows(dolock = 0)
|
s.setupwindows(dolock = 0)
|
||||||
@ -330,8 +335,8 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
print msg
|
print msg
|
||||||
return
|
return
|
||||||
if color:
|
if color:
|
||||||
s.gettf().setcolor(color)
|
s.gettf(lock = 0).setcolor(color, lock = 0)
|
||||||
s._addline_unlocked(msg, s.gettf().getcolor())
|
s._addline_unlocked(msg, s.gettf(lock = 0).getcolor())
|
||||||
s.logwindow.refresh()
|
s.logwindow.refresh()
|
||||||
finally:
|
finally:
|
||||||
s.iolock.release()
|
s.iolock.release()
|
||||||
|
Loading…
Reference in New Issue
Block a user