1
0
mirror of https://github.com/OfflineIMAP/offlineimap.git synced 2024-06-26 07:29:03 +02:00
offlineimap/head/offlineimap/ui/TTY.py

52 lines
1.7 KiB
Python
Raw Normal View History

2002-06-21 07:42:39 +02:00
from UIBase import UIBase
2002-06-21 07:29:12 +02:00
from getpass import getpass
2002-06-21 09:25:24 +02:00
import select, sys
2002-06-21 07:29:12 +02:00
2002-06-21 07:42:39 +02:00
class TTYUI(UIBase):
def __init__(self, verbose = 0):
self.verbose = 0
2002-06-21 07:29:12 +02:00
def _msg(s, msg):
print msg
2002-07-04 04:14:07 +02:00
sys.stdout.flush()
2002-06-21 07:29:12 +02:00
def getpass(s, accountname, config):
2002-06-21 07:42:39 +02:00
return getpass("%s: Enter password for %s on %s: " %
(accountname, config.get(accountname, "remoteuser"),
config.get(accountname, "remotehost")))
2002-06-21 07:42:39 +02:00
def syncingmessages(s, sr, sf, dr, df):
if s.verbose:
UIBase.syncingmessages(s, sr, sf, dr, df)
def loadmessagelist(s, repos, folder):
if s.verbose:
UIBase.syncingmessages(s, repos, folder)
2002-06-21 07:29:12 +02:00
2002-06-21 07:42:39 +02:00
def messagelistloaded(s, repos, folder, count):
if s.verbose:
UIBase.messagelistloaded(s, repos, folder, count)
2002-06-21 09:25:24 +02:00
def sleep(s, sleepsecs):
try:
UIBase.sleep(s, sleepsecs)
except KeyboardInterrupt:
sys.stdout.write("Timer interrupted at user request; program terminating. \n")
return 2
2002-06-21 09:25:24 +02:00
def sleeping(s, sleepsecs, remainingsecs):
if remainingsecs > 0:
sys.stdout.write("Next sync in %d:%02d (press Enter to sync now, Ctrl-C to abort) \r" % \
2002-06-21 09:25:24 +02:00
(remainingsecs / 60, remainingsecs % 60))
sys.stdout.flush()
else:
sys.stdout.write("Wait done, proceeding with sync.... \n")
2002-06-21 09:25:24 +02:00
if sleepsecs > 0:
if len(select.select([sys.stdin], [], [], sleepsecs)[0]):
sys.stdin.readline()
2002-06-21 09:25:24 +02:00
return 1
return 0
2002-06-21 09:25:24 +02:00