]> code.delx.au - offlineimap/blob - offlineimap/head/offlineimap/ui/Noninteractive.py
62f1603e12ece9b365fcbf0cfa26291cb5f09bc9
[offlineimap] / offlineimap / head / offlineimap / ui / Noninteractive.py
1 # Noninteractive UI
2 # Copyright (C) 2002 John Goerzen
3 # <jgoerzen@complete.org>
4 #
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; version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 import sys, time
19 from UIBase import UIBase
20
21 class Basic(UIBase):
22 def getpass(s, accountname, config, errmsg = None):
23 raise NotImplementedError, "Prompting for a password is not supported in noninteractive mode."
24
25 def _msg(s, msg):
26 print msg
27 sys.stdout.flush()
28
29 def warn(s, msg, minor = 0):
30 warntxt = 'WARNING'
31 if minor:
32 warntxt = 'warning'
33 sys.stderr.write(warntxt + ": " + str(msg) + "\n")
34
35 def sleep(s, sleepsecs):
36 if s.verbose >= 0:
37 s._msg("Sleeping for %d:%02d" % (sleepsecs / 60, sleepsecs % 60))
38 UIBase.sleep(s, sleepsecs)
39
40 def sleeping(s, sleepsecs, remainingsecs):
41 if sleepsecs > 0:
42 time.sleep(sleepsecs)
43 return 0
44
45 class Quiet(Basic):
46 def __init__(s, config, verbose = -1):
47 Basic.__init__(s, config, verbose)