/offlineimap/head: changeset 278
Moved password promting into imapserver.py. Passwords are now asked for on-demand and typos will no longer crash the program (the user will be re-prompted). Closes: #162672.
This commit is contained in:
@@ -25,21 +25,32 @@ class TTYUI(UIBase):
|
||||
def __init__(s, config, verbose = 0):
|
||||
UIBase.__init__(s, config, verbose)
|
||||
s.iswaiting = 0
|
||||
s.outputlock = Lock()
|
||||
|
||||
def isusable(s):
|
||||
return sys.stdout.isatty() and sys.stdin.isatty()
|
||||
|
||||
def _msg(s, msg):
|
||||
if (currentThread().getName() == 'MainThread'):
|
||||
print msg
|
||||
else:
|
||||
print "%s:\n %s" % (currentThread().getName(), msg)
|
||||
sys.stdout.flush()
|
||||
s.outputlock.acquire()
|
||||
try:
|
||||
if (currentThread().getName() == 'MainThread'):
|
||||
print msg
|
||||
else:
|
||||
print "%s:\n %s" % (currentThread().getName(), msg)
|
||||
sys.stdout.flush()
|
||||
finally:
|
||||
s.outputlock.release()
|
||||
|
||||
def getpass(s, accountname, config):
|
||||
return getpass("%s: Enter password for %s on %s: " %
|
||||
(accountname, config.get(accountname, "remoteuser"),
|
||||
config.get(accountname, "remotehost")))
|
||||
def getpass(s, accountname, config, errmsg = None):
|
||||
if errmsg:
|
||||
s._msg("%s: %s" % (accountname, errmsg))
|
||||
s.outputlock.acquire()
|
||||
try:
|
||||
return getpass("%s: Enter password for %s on %s: " %
|
||||
(accountname, config.get(accountname, "remoteuser"),
|
||||
config.get(accountname, "remotehost")))
|
||||
finally:
|
||||
s.outputlock.release()
|
||||
|
||||
def sleep(s, sleepsecs):
|
||||
s.iswaiting = 1
|
||||
|
@@ -27,13 +27,16 @@ from Queue import Queue
|
||||
from UIBase import UIBase
|
||||
|
||||
class PasswordDialog:
|
||||
def __init__(self, accountname, config, master=None):
|
||||
def __init__(self, accountname, config, master=None, errmsg = None):
|
||||
self.top = Toplevel(master)
|
||||
self.top.title(version.productname + " Password Entry")
|
||||
self.label = Label(self.top,
|
||||
text = "%s: Enter password for %s on %s: " % \
|
||||
(accountname, config.get(accountname, "remoteuser"),
|
||||
config.get(accountname, "remotehost")))
|
||||
text = ''
|
||||
if errmsg:
|
||||
text = '%s: %s\n' % (accountname, errmsg)
|
||||
text += "%s: Enter password for %s on %s: " % \
|
||||
(accountname, config.get(accountname, "remoteuser"),
|
||||
config.get(accountname, "remotehost"))
|
||||
self.label = Label(self.top, text = text)
|
||||
self.label.pack()
|
||||
|
||||
self.entry = Entry(self.top, show='*')
|
||||
@@ -171,8 +174,8 @@ class VerboseUI(UIBase):
|
||||
s.top.mainloop()
|
||||
s.notdeleted = 0
|
||||
|
||||
def getpass(s, accountname, config):
|
||||
pd = PasswordDialog(accountname, config)
|
||||
def getpass(s, accountname, config, errmsg = None):
|
||||
pd = PasswordDialog(accountname, config, errmsg = errmsg)
|
||||
return pd.getpassword()
|
||||
|
||||
def gettf(s, newtype=ThreadFrame, master = None):
|
||||
|
@@ -92,7 +92,7 @@ class UIBase:
|
||||
|
||||
################################################## INPUT
|
||||
|
||||
def getpass(s, accountname, config):
|
||||
def getpass(s, accountname, config, errmsg = None):
|
||||
raise NotImplementedError
|
||||
|
||||
def folderlist(s, list):
|
||||
|
Reference in New Issue
Block a user