Added FileIdler
authorMark Tearle <mtearle@ucc.gu.uwa.edu.au>
Fri, 1 Oct 2004 09:37:10 +0000 (09:37 +0000)
committerMark Tearle <mtearle@ucc.gu.uwa.edu.au>
Fri, 1 Oct 2004 09:37:10 +0000 (09:37 +0000)
sql-edition/servers/Idler.py
sql-edition/servers/VendServer.py

index eedfe73..5fe61cf 100755 (executable)
@@ -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 
index b623be6..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 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 = [
                ]

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