Commit 8796ba14 authored by David Adam's avatar David Adam Committed by Mark Tearle
Browse files

switch from popen2 to subprocess (fix deprecation warnings)


Signed-off-by: default avatarMark Tearle <[email protected]>
parent 61df7b6a
#!/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):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment