/offlineimap/head: changeset 302

Now capable of actually reading passwords.
This commit is contained in:
jgoerzen 2003-01-05 09:07:00 +01:00
parent ba0c95f6bc
commit 9df89638f5

View File

@ -194,6 +194,22 @@ class Blinkenlights(BlinkenBase, UIBase):
def keypress(s, key): def keypress(s, key):
s._msg("Key pressed: " + str(key)) s._msg("Key pressed: " + str(key))
def getpass(s, accountname, config, errmsg = None):
s.inputhandler.input_acquire()
s.iolock.acquire()
try:
s.gettf().setcolor('white')
s._addline_unlocked(" *** Input Required", s.gettf().getcolor())
s._addline_unlocked(" *** Please enter password for account %s: ", accountname,
s.gettf().getcolor())
s.logwindow.refresh()
password = s.logwindow.getstr()
finally:
s.iolock.release()
s.inputhandler.input_release()
s._msg(" Got password '%s'" % password)
return password
def setupwindows(s): def setupwindows(s):
s.bannerwindow = curses.newwin(1, s.c.width, 0, 0) s.bannerwindow = curses.newwin(1, s.c.width, 0, 0)
s.drawbanner() s.drawbanner()
@ -216,15 +232,19 @@ class Blinkenlights(BlinkenBase, UIBase):
s.bannerwindow.noutrefresh() s.bannerwindow.noutrefresh()
def drawlog(s): def drawlog(s):
s.logwindow.bkgd(' ', s.c.getpair(curses.COLOR_WHITE, curses.COLOR_BLACK)) s.iolock.acquire()
for line, color in s.text: try:
s.logwindow.addstr(line + "\n", color) s.logwindow.bkgd(' ', s.c.getpair(curses.COLOR_WHITE, curses.COLOR_BLACK))
s.logwindow.noutrefresh() for line, color in s.text:
s.logwindow.addstr(line + "\n", color)
s.logwindow.noutrefresh()
finally:
s.iolock.release()
def gettf(s): def gettf(s):
return s.tf return s.tf
def _msg(s, msg): def _msg(s, msg, color = None):
if "\n" in msg: if "\n" in msg:
for thisline in msg.split("\n"): for thisline in msg.split("\n"):
s._msg(thisline) s._msg(thisline)
@ -235,15 +255,20 @@ class Blinkenlights(BlinkenBase, UIBase):
# For dumping out exceptions and stuff. # For dumping out exceptions and stuff.
print msg print msg
return return
color = s.gettf().getcolor() if color:
s.logwindow.addstr(msg + "\n", color) s.gettf().setcolor(color)
s.text.append((msg, color)) s._addline_unlocked(msg, s.gettf().getcolor())
while len(s.text) > s.logheight:
s.text = s.text[1:]
s.logwindow.refresh() s.logwindow.refresh()
finally: finally:
s.iolock.release() s.iolock.release()
def _addline_unlocked(s, msg, color):
s.logwindow.addstr(msg + "\n", color)
s.text.append((msg, color))
while len(s.text) > s.logheight:
s.text = s.text[1:]
def terminate(s, exitstatus = 0): def terminate(s, exitstatus = 0):
s.c.stop() s.c.stop()
UIBase.terminate(s, exitstatus) UIBase.terminate(s, exitstatus)
@ -254,7 +279,7 @@ class Blinkenlights(BlinkenBase, UIBase):
def mainException(s): def mainException(s):
s.c.stop() s.c.stop()
UIBase.mainException() UIBase.mainException(s)
if __name__ == '__main__': if __name__ == '__main__':
x = Blinkenlights(None) x = Blinkenlights(None)