import os
import select
import signal
-import string
import sys
import time
"""Fork a subprocess with designated COMMAND (default, self.cmd)."""
if cmd:
self.cmd = cmd
- cmd = string.split(self.cmd)
+ cmd = self.cmd.split()
pRc, cWp = os.pipe() # parent-read-child, child-write-parent
cRp, pWc = os.pipe() # child-read-parent, parent-write-child
pRe, cWe = os.pipe() # parent-read-error, child-write-error
any newline."""
if self.buf:
- to = string.find(self.buf, '\n')
+ to = self.buf.find('\n')
if to != -1:
got, self.buf = self.buf[:to+1], self.buf[to+1:]
return got # ===>
if sel[0]:
got = got + os.read(self.fd, self.chunkSize)
- to = string.find(got, '\n')
+ to = got.find('\n')
if to != -1:
got, self.buf = got[:to+1], got[to+1:]
return got # ===>
line = f.readline()[:-1]
if line:
try:
- l = string.atoi(line)
+ l = int(line)
except ValueError:
raise IOError(("corrupt %s file structure"
% self.__class__.__name__))
raise ValueError("ph failed match: '%s'" % response) # ===>
for line in response:
# convert to a dict:
- line = string.splitfields(line, ':')
- it[string.strip(line[0])] = (
- string.strip(string.join(line[1:])))
+ line = line.split(':')
+ it[line.strip([0])] = (''.join(line[1:])).strip()
def getreply(self):
"""Consume next response from ph, returning list of lines or string
while iterations < maxIter:
got = got + self.proc.readPendingChars()
# Strip out all but the last incomplete line:
- got = string.splitfields(got, '\n')[-1]
+ got = got.split('\n')[-1]
if got == 'ph> ':
return # Ok. ===>
time.sleep(pause)