From f68b626cb4d8297e3bf93291d47043642de383e1 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sun, 5 Dec 2010 15:35:01 +0100 Subject: [PATCH] Don't display sleeping every second on the screen Only every 10 seconds. Also fix up the documentation of that function while at it. The Curses ui actually implements user abort it seems. Not sure if we could do the same in the UIBase, but that is for another time. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/ui/UIBase.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index b1176fd..bb927c0 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -346,18 +346,23 @@ class UIBase: # retrieved signal while sleeping: 1 means immediately resynch, 2 means immediately die except Empty: # no signal - abortsleep = s.sleeping(1, sleepsecs) - sleepsecs -= 1 + abortsleep = s.sleeping(10, sleepsecs) + sleepsecs -= 10 s.sleeping(0, 0) # Done sleeping. return abortsleep def sleeping(s, sleepsecs, remainingsecs): - """Sleep for sleepsecs, remainingsecs to go. - If sleepsecs is 0, indicates we're done sleeping. + """Sleep for sleepsecs, display remainingsecs to go. - Return 0 for normal sleep, or 1 to indicate a request - to sync immediately.""" - s._msg("Next refresh in %d seconds" % remainingsecs) + Does nothing if sleepsecs <= 0. + Display a message on the screen every 10 seconds. + + This implementation in UIBase does not support this, but some + implementations return 0 for successful sleep and 1 for an + 'abort', ie a request to sync immediately. + """ if sleepsecs > 0: + if remainingsecs % 10 == 0: + s._msg("Next refresh in %d seconds" % remainingsecs) time.sleep(sleepsecs) return 0