create pipe idler
authorBernard Blackham <dagobah@ucc.gu.uwa.edu.au>
Sun, 12 Dec 2004 06:51:06 +0000 (06:51 +0000)
committerBernard Blackham <dagobah@ucc.gu.uwa.edu.au>
Sun, 12 Dec 2004 06:51:06 +0000 (06:51 +0000)
sql-edition/servers/Idler.py
sql-edition/servers/VendServer.py

index 5fe61cf..2670b51 100755 (executable)
@@ -247,6 +247,19 @@ class FortuneIdler(StringIdler):
        def affinity(self):
                return 20
 
+class PipeIdler(StringIdler):
+       def __init__(self, v, command):
+               text = "I ate my cookie...."
+               if os.access(command,os.F_OK|os.X_OK):
+                       (stdout, stdin) = popen2.popen2(command)
+                       text = string.join(stdout.readlines())
+                       stdout.close()
+                       stdin.close()
+               StringIdler.__init__(self, v, text,repeat=False)
+
+       def affinity(self):
+               return 20
+
 class FileIdler(StringIdler):
        def __init__(self, v, thefile=None, repeat=False):
                text = "I broke my wookie...."
index d6f48c9..93f22f2 100755 (executable)
@@ -205,7 +205,8 @@ def setup_idlers(v):
                 GrayIdler(v,one="/",zero="\\",reorder=1),
                StringIdler(v, text=str(math.e) + "            "),
                 GrayIdler(v,one="X",zero="O",reorder=1),
-               StringIdler(v, text="I want some pizza - please call Pizza Hut Shenton Park on +61 8 9381 9979 - and order as Quinn - I am getting really hungry", repeat=False),
+               StringIdler(v, text="    I want some pizza - please call Pizza Hut Shenton Park on +61 8 9381 9979 - and order as Quinn - I am getting really hungry", repeat=False),
+               PipeIdler(v, "/usr/bin/ypcat", "passwd"),
                FortuneIdler(v),
                ClockIdler(v),
                StringIdler(v),

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