]>
code.delx.au - offlineimap/blob - offlineimap/ui/TTY.py
2 # Copyright (C) 2002 John Goerzen
3 # <jgoerzen@complete.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 from UIBase
import UIBase
20 from getpass
import getpass
22 from threading
import *
25 def __init__(s
, config
, verbose
= 0):
26 UIBase
.__init
__(s
, config
, verbose
)
31 return sys
.stdout
.isatty() and sys
.stdin
.isatty()
34 s
.outputlock
.acquire()
36 if (currentThread().getName() == 'MainThread'):
39 print "%s:\n %s" % (currentThread().getName(), msg
)
42 s
.outputlock
.release()
44 def getpass(s
, accountname
, config
, errmsg
= None):
46 s
._msg
("%s: %s" % (accountname
, errmsg
))
47 s
.outputlock
.acquire()
49 return getpass("%s: Enter password: " % accountname
)
51 s
.outputlock
.release()
54 if isinstance(sys
.exc_info()[1], KeyboardInterrupt) and \
56 sys
.stdout
.write("Timer interrupted at user request; program terminating. \n")
59 UIBase
.mainException(s
)