X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=subproc.py;h=1828b1c240151e1df7d8a3d8d809e912f6820c6f;hb=a7daaf8f136d162109a5541a98f44991855628cc;hp=c7fd11629c52a526d2cef7b1e1eb63ede7565fac;hpb=a04eaa0346e8aa5ad86a195f8f4d36487ebfe09c;p=bookmarks_db.git diff --git a/subproc.py b/subproc.py index c7fd116..1828b1c 100644 --- a/subproc.py +++ b/subproc.py @@ -16,7 +16,7 @@ Subprocess class features: __version__ = "Revision: 1.15 " -# Id: subproc.py,v 1.15 1998/12/14 20:53:16 klm Exp +# Id: subproc.py,v 1.15 1998/12/14 20:53:16 klm Exp # Originally by ken manheimer, ken.manheimer@nist.gov, jan 1995. # Prior art: Initially based python code examples demonstrating usage of pipes @@ -40,6 +40,9 @@ __version__ = "Revision: 1.15 " # # ken.manheimer@nist.gov +# This is a modified version by Oleg Broytman . +# The original version is still preserved at +# https://www.python.org/ftp/python/contrib-09-Dec-1999/System/subproc.tar.gz import sys, os, string, time, types import select @@ -206,7 +209,7 @@ class Subprocess: got0 = self.readPendingChars(n) got = got + got0 n = n - len(got0) - return got + return got def readPendingChars(self, max=None): """Read all currently pending subprocess output as a single string.""" return self.readbuf.readPendingChars(max) @@ -401,15 +404,15 @@ class ReadBuf: got = "" if self.buf: - if (max > 0) and (len(self.buf) > max): - got = self.buf[0:max] - self.buf = self.buf[max:] - else: - got, self.buf = self.buf, '' - return got + if (max > 0) and (len(self.buf) > max): + got = self.buf[0:max] + self.buf = self.buf[max:] + else: + got, self.buf = self.buf, '' + return got if self.eof: - return '' + return '' sel = select.select([self.fd], [], [self.fd], 0) if sel[2]: @@ -590,7 +593,7 @@ class Ph: line = string.splitfields(line, ':') it[string.strip(line[0])] = ( string.strip(string.join(line[1:]))) - + def getreply(self): """Consume next response from ph, returning list of lines or string err."""