From: Mark Tearle Date: Fri, 1 Oct 2004 09:37:10 +0000 (+0000) Subject: Added FileIdler X-Git-Tag: IMPORT-FROM-UCCCVS~56 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=00324dcdcc17c73c94696a8112f2fe41f2c28e58;p=uccvend-vendserver.git Added FileIdler --- diff --git a/sql-edition/servers/Idler.py b/sql-edition/servers/Idler.py index eedfe73..5fe61cf 100755 --- a/sql-edition/servers/Idler.py +++ b/sql-edition/servers/Idler.py @@ -246,3 +246,16 @@ class FortuneIdler(StringIdler): def affinity(self): return 20 + +class FileIdler(StringIdler): + def __init__(self, v, thefile=None, repeat=False): + text = "I broke my wookie...." + + if file and os.access(thefile,os.F_OK|os.R_OK): + f = file(thefile,'r') + text = string.join(f.readlines()) + f.close() + StringIdler.__init__(self, v, text,repeat=repeat) + + def affinity(self): + return 8 diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index b623be6..e17de1c 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,FortuneIdler +from Idler import TrainIdler,GrayIdler,StringIdler,ClockIdler,FortuneIdler,FileIdler import socket from posix import geteuid @@ -189,21 +189,23 @@ idler = None def setup_idlers(v): global idlers, idler idlers = [ + GrayIdler(v), StringIdler(v, text="Kill 'em all", repeat=False), + GrayIdler(v,one="*",zero="-"), StringIdler(v, text=CREDITS), + GrayIdler(v,one="/",zero="\\"), + FileIdler(v, '/etc/passwd'), + GrayIdler(v,one="X",zero="O"), + FileIdler(v, '/usr/share/common-licenses/GPL-2'), + GrayIdler(v,one="*",zero="-",reorder=1), StringIdler(v, text=str(math.pi) + " "), + GrayIdler(v,one="/",zero="\\",reorder=1), StringIdler(v, text=str(math.e) + " "), + GrayIdler(v,one="X",zero="O",reorder=1), FortuneIdler(v), ClockIdler(v), StringIdler(v), - GrayIdler(v), TrainIdler(v), - GrayIdler(v,one="*",zero="-"), - GrayIdler(v,one="/",zero="\\"), - GrayIdler(v,one="X",zero="O"), - GrayIdler(v,one="*",zero="-",reorder=1), - GrayIdler(v,one="/",zero="\\",reorder=1), - GrayIdler(v,one="X",zero="O",reorder=1), ] disabled = [ ]