]> code.delx.au - offlineimap/blob - offlineimap/head/offlineimap/ui/Noninteractive.py
/offlineimap/head: changeset 274
[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; 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 import sys, time
20 from UIBase import UIBase
21
22 class Basic(UIBase):
23 def getpass(s, accountname, config):
24 raise NotImplementedError, "Prompting for a password is not supported in noninteractive mode."
25
26 def _msg(s, msg):
27 print msg
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)