X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=subproc.py;h=69bd13bc5cff42debdd86326905e8e571220455d;hb=6d04cae4210534002c2e6ac94d08c48f3d667646;hp=886dc4727a32f7c956ef255fbb00361916c9b996;hpb=a66745abb2ff9ec50535f608d1deb468bad4d85c;p=bookmarks_db.git diff --git a/subproc.py b/subproc.py index 886dc47..69bd13b 100755 --- a/subproc.py +++ b/subproc.py @@ -49,7 +49,6 @@ __version__ = "Revision: 2.0 " import os import select import signal -import string import sys import time @@ -101,7 +100,7 @@ class Subprocess: """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 @@ -472,7 +471,7 @@ class ReadBuf: 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 # ===> @@ -493,7 +492,7 @@ class ReadBuf: 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 # ===> @@ -541,11 +540,11 @@ class RecordFile: 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__)) - return f.read(l) + return f.read(_l) else: # EOF. return '' @@ -627,9 +626,8 @@ class Ph: 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 @@ -675,7 +673,7 @@ class Ph: 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)