Added FileIdler
[uccvend-vendserver.git] / sql-edition / servers / VendServer.py
index eda4dc9..e17de1c 100755 (executable)
@@ -15,7 +15,7 @@ from VendingMachine import VendingMachine, VendingException
 from MessageKeeper import MessageKeeper
 from HorizScroll import HorizScroll
 from random import random, seed
 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,FileIdler
 import socket
 from posix import geteuid
 
 import socket
 from posix import geteuid
 
@@ -189,25 +189,43 @@ idler = None
 def setup_idlers(v):
        global idlers, idler
        idlers = [
 def setup_idlers(v):
        global idlers, idler
        idlers = [
-               ClockIdler(v),
-               StringIdler(v),
+                GrayIdler(v),
+               StringIdler(v, text="Kill 'em all", repeat=False),
+                GrayIdler(v,one="*",zero="-"),
                StringIdler(v, text=CREDITS),
                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) + "            "),
                StringIdler(v, text=str(math.pi) + "            "),
+                GrayIdler(v,one="/",zero="\\",reorder=1),
                StringIdler(v, text=str(math.e) + "            "),
                StringIdler(v, text=str(math.e) + "            "),
-               GrayIdler(v),
+                GrayIdler(v,one="X",zero="O",reorder=1),
+               FortuneIdler(v),
+               ClockIdler(v),
+               StringIdler(v),
                TrainIdler(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 = [
                ]
        idler = choose_idler()
 
 def choose_idler():
        global idler
                ]
        idler = choose_idler()
 
 def choose_idler():
        global idler
-       idler = idlers[int(random()*len(idlers))]
+       iiindex = 0
+
+       if idler:
+               iiindex = idlers.index(idler)
+
+       iilen = len(idlers)
+
+       move = int(random()*len(idlers)) + 1
+
+       while move >= 0:
+               idler = idlers[( (iiindex + 1) % iilen)]
+               move = move - idler.affinity()
+
        idler.reset()
 
 def idle_step():
        idler.reset()
 
 def idle_step():

UCC git Repository :: git.ucc.asn.au