From 33cd17ec630302925f6b36fcc45923c882a970f5 Mon Sep 17 00:00:00 2001 From: Mark Tearle Date: Wed, 29 Sep 2004 10:02:23 +0000 Subject: [PATCH] add support for one shot Idlers --- sql-edition/servers/Idler.py | 18 ++++++++++++++---- sql-edition/servers/VendServer.py | 5 ++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sql-edition/servers/Idler.py b/sql-edition/servers/Idler.py index 48e819a..a231d96 100755 --- a/sql-edition/servers/Idler.py +++ b/sql-edition/servers/Idler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import string +import string, time from random import random from MessageKeeper import MessageKeeper @@ -15,6 +15,9 @@ class Idler: def reset(self): pass + + def finished(self): + return False class TrainIdler(Idler): def __init__(self, v): @@ -210,6 +213,13 @@ class StringIdler(Idler): def next(self): self.mk.update_display() - def reset(self): - pass - #self.mk.update_display(forced=True) +class ClockIdler(Idler): + def __init__(self, v): + self.v = v + self.last = None + + def next(self): + output = time.strftime("%H:%M:%S") + if output != self.last: + self.v.display(" %8.8s " % (output)) + self.last = output diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index c82dda8..eda4dc9 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -15,7 +15,7 @@ from VendingMachine import VendingMachine, VendingException from MessageKeeper import MessageKeeper from HorizScroll import HorizScroll from random import random, seed -from Idler import TrainIdler,GrayIdler,StringIdler +from Idler import TrainIdler,GrayIdler,StringIdler,ClockIdler import socket from posix import geteuid @@ -189,6 +189,7 @@ idler = None def setup_idlers(v): global idlers, idler idlers = [ + ClockIdler(v), StringIdler(v), StringIdler(v, text=CREDITS), StringIdler(v, text=str(math.pi) + " "), @@ -211,6 +212,8 @@ def choose_idler(): def idle_step(): global idler + if idler.finished(): + choose_idler() idler.next() def run_forever(rfh, wfh, options, cf): -- 2.20.1