]> code.delx.au - offlineimap/blob - offlineimap/ui/Noninteractive.py
Update FSF address
[offlineimap] / 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; either version 2 of the License, or
8 # (at your option) any later version.
9 #
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.
14 #
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
18
19 import sys, time
20 from UIBase import UIBase
21
22 class Basic(UIBase):
23 def getpass(s, accountname, config, errmsg = None):
24 raise NotImplementedError, "Prompting for a password is not supported in noninteractive mode."
25
26 def _display(s, msg):
27 print msg
28 sys.stdout.flush()
29
30 def warn(s, msg, minor = 0):
31 warntxt = 'WARNING'
32 if minor:
33 warntxt = 'warning'
34 sys.stderr.write(warntxt + ": " + str(msg) + "\n")
35
36 def sleep(s, sleepsecs):
37 if s.verbose >= 0:
38 s._msg("Sleeping for %d:%02d" % (sleepsecs / 60, sleepsecs % 60))
39 UIBase.sleep(s, sleepsecs)
40
41 def sleeping(s, sleepsecs, remainingsecs):
42 if sleepsecs > 0:
43 time.sleep(sleepsecs)
44 return 0
45
46 class Quiet(Basic):
47 def __init__(s, config, verbose = -1):
48 Basic.__init__(s, config, verbose)