Commit c710fe05 by Matthias Putz

Portable: fixed -p option for forall

parent a4168527
...@@ -64,6 +64,12 @@ class file_reader(object): ...@@ -64,6 +64,12 @@ class file_reader(object):
def read(self, bufsize): def read(self, bufsize):
return self.fd.read(bufsize) return self.fd.read(bufsize)
def close(self):
return self.fd.close()
def src(self):
return self.fd
class socket_reader(): class socket_reader():
"""select socket with file descriptor class""" """select socket with file descriptor class"""
def __init__(self, src, dest, std_name=''): def __init__(self, src, dest, std_name=''):
...@@ -98,12 +104,20 @@ class socket_reader(): ...@@ -98,12 +104,20 @@ class socket_reader():
return self.server_socket.recv(bufsize) return self.server_socket.recv(bufsize)
except Exception as e: except Exception as e:
Trace("failed to read from server socket: " + e.strerror) Trace("failed to read from server socket: " + e.strerror)
self.close()
def close(self):
if self.client_socket:
self.client_socket.close() self.client_socket.close()
if self.server_socket:
self.server_socket.close() self.server_socket.close()
def fileno(self): def fileno(self):
return self.server_socket.fileno() return self.server_socket.fileno()
def src(self):
return self.src
def os_symlink(src, dst): def os_symlink(src, dst):
if isUnix(): if isUnix():
......
...@@ -364,12 +364,14 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): ...@@ -364,12 +364,14 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config):
# buf = s.fd.read(4096) # buf = s.fd.read(4096)
buf = s.read(4096) buf = s.read(4096)
if not buf: if not buf:
s.fd.close() # s.fd.close()
s.close()
s_in.remove(s) s_in.remove(s)
continue continue
if not opt.verbose: if not opt.verbose:
if s.fd != p.stdout: # if s.fd != p.stdout:
if s.src != p.stdout:
errbuf += buf errbuf += buf
continue continue
......
Markdown is supported
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