From: Mark Tearle Date: Thu, 30 Sep 2004 15:17:44 +0000 (+0000) Subject: fortune Idler X-Git-Tag: IMPORT-FROM-UCCCVS~58 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=91714f5d8c77c1dff1a169cce7c5874b053b7810;p=uccvend-vendserver.git fortune Idler --- diff --git a/sql-edition/servers/Idler.py b/sql-edition/servers/Idler.py index 392da6b..fc7573a 100755 --- a/sql-edition/servers/Idler.py +++ b/sql-edition/servers/Idler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import string, time +import string, time, popen2, os from random import random from MessageKeeper import MessageKeeper @@ -19,6 +19,9 @@ class Idler: def finished(self): return False + def affinity(self): + return 1 + class TrainIdler(Idler): def __init__(self, v): self.idle_state = 0 @@ -226,3 +229,17 @@ class ClockIdler(Idler): if output != self.last: self.v.display(" %8.8s " % (output)) self.last = output + +class FortuneIdler(StringIdler): + def __init__(self, v): + fortune = "/usr/games/fortune" + text = "I broke my wookie...." + if os.access(fortune,os.F_OK|os.X_OK): + (stdout, stdin) = popen2.popen2(fortune) + text = string.join(stdout.readlines()) + stdout.close() + stdin.close() + StringIdler.__init__(self, v, text,repeat=False) + + def affinity(self): + return 15 diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index d15165d..3f2c72f 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,ClockIdler +from Idler import TrainIdler,GrayIdler,StringIdler,ClockIdler,FortuneIdler import socket from posix import geteuid @@ -189,12 +189,13 @@ idler = None def setup_idlers(v): global idlers, idler idlers = [ - ClockIdler(v), StringIdler(v, text="Kill 'em all", repeat=False), StringIdler(v, text=CREDITS), StringIdler(v, text=str(math.pi) + " "), StringIdler(v, text=str(math.e) + " "), StringIdler(v), + FortuneIdler(v), + ClockIdler(v), GrayIdler(v), TrainIdler(v), GrayIdler(v,one="*",zero="-"),