/head: changeset 56
Integrated more functional sleep commands
This commit is contained in:
parent
fb055de114
commit
6162100487
@ -2,6 +2,8 @@ offlineimap (1.0.4) unstable; urgency=low
|
||||
|
||||
* Deletion of more than one message has been optimized. This could make
|
||||
deleting large numbers of messages far faster.
|
||||
* Moved more sleep code into ui layer. Fancier sleep actions are now
|
||||
possible.
|
||||
|
||||
-- John Goerzen <jgoerzen@complete.org> Tue, 2 Jul 2002 14:16:04 -0500
|
||||
|
||||
|
@ -135,11 +135,8 @@ syncitall()
|
||||
if config.has_option('general', 'autorefresh'):
|
||||
refreshperiod = config.getint('general', 'autorefresh') * 60
|
||||
while 1:
|
||||
sleepamount = refreshperiod
|
||||
abortsleep = 0
|
||||
while sleepamount > 0 and not abortsleep:
|
||||
abortsleep = ui.sleeping(1, sleepamount)
|
||||
sleepamount -= 1
|
||||
ui.sleeping(0, 0) # Done sleeping.
|
||||
syncitall()
|
||||
if ui.sleep(refreshperiod) == 2:
|
||||
break
|
||||
else:
|
||||
syncitall()
|
||||
|
||||
|
@ -25,13 +25,20 @@ class TTYUI(UIBase):
|
||||
if s.verbose:
|
||||
UIBase.messagelistloaded(s, repos, folder, count)
|
||||
|
||||
def sleep(s, sleepsecs):
|
||||
try:
|
||||
UIBase.sleep(s, sleepsecs)
|
||||
except KeyboardInterrupt:
|
||||
sys.stdout.write("Timer interrupted at user request; program terminating. \n")
|
||||
return 2
|
||||
|
||||
def sleeping(s, sleepsecs, remainingsecs):
|
||||
if remainingsecs > 0:
|
||||
sys.stdout.write("Next sync in %d:%02d (press Enter to sync now) \r" % \
|
||||
sys.stdout.write("Next sync in %d:%02d (press Enter to sync now, Ctrl-C to abort) \r" % \
|
||||
(remainingsecs / 60, remainingsecs % 60))
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
sys.stdout.write("Wait done, proceeding with sync.... \n")
|
||||
sys.stdout.write("Wait done, proceeding with sync.... \n")
|
||||
|
||||
if sleepsecs > 0:
|
||||
if len(select.select([sys.stdin], [], [], sleepsecs)[0]):
|
||||
|
@ -110,6 +110,21 @@ class UIBase:
|
||||
|
||||
################################################## Other
|
||||
|
||||
def sleep(s, sleepsecs):
|
||||
"""This function does not actually output anything, but handles
|
||||
the overall sleep, dealing with updates as necessary. It will,
|
||||
however, call sleeping() which DOES output something.
|
||||
|
||||
Returns 0 if timeout expired, 1 if there is a request to cancel
|
||||
the timer, and 2 if there is a request to abort the program."""
|
||||
|
||||
abortsleep = 0
|
||||
while sleepsecs > 0 and not abortsleep:
|
||||
abortsleep = s.sleeping(1, sleepsecs)
|
||||
sleepsecs -= 1
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user