X-Git-Url: https://git.ucc.asn.au/?p=uccvend-vendserver.git;a=blobdiff_plain;f=sql-edition%2Fservers%2FIdler.py;h=5b6645517945891c49dd79b8ff6f1c62077410a3;hp=ff73c2af89779c1092a7cd0ff79a3df0a8a40ab6;hb=8796ba14bcff4d89b76d32d28146527fd6f329f1;hpb=61df7b6ac502410b6de0d61b67e4a521e404c6db diff --git a/sql-edition/servers/Idler.py b/sql-edition/servers/Idler.py index ff73c2a..5b66455 100755 --- a/sql-edition/servers/Idler.py +++ b/sql-edition/servers/Idler.py @@ -1,6 +1,7 @@ #!/usr/bin/env python -import string, time, popen2, os +import string, time, os +from subprocess import Popen, PIPE from random import random from MessageKeeper import MessageKeeper @@ -281,10 +282,8 @@ class FortuneIdler(StringIdler): 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() + (lines, unused) = Popen((fortune,), close_fds=True, stdout=PIPE).communicate() + text = string.join(lines) StringIdler.__init__(self, v, text,repeat=False) def affinity(self): @@ -294,10 +293,8 @@ class PipeIdler(StringIdler): def __init__(self, v, command, args): text = "I ate my cookie...." if os.access(command,os.F_OK|os.X_OK): - (stdout, stdin) = popen2.popen2(command+' '+args) - text = string.join(stdout.readlines()) - stdout.close() - stdin.close() + (lines, unused) = Popen([command,] + args.split(), close_fds=True, stdout=PIPE).communicate() + text = string.join(lines) StringIdler.__init__(self, v, text,repeat=False) def affinity(self):