summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-12-01 15:28:35 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-12-01 15:28:35 +0000
commitf491083870a5d8aad426f8d0b9b52e832e13788d (patch)
tree4ac96c3c47be4e5310d4ddb93757ff23289d4fd4
parentd37acb166d2416f5ae142a95655666fb19966cf7 (diff)
downloadimport-f491083870a5d8aad426f8d0b9b52e832e13788d.tar.gz
Let Popen handle multiplexing
-rwxr-xr-xexts/pip.to_lorry24
1 files changed, 6 insertions, 18 deletions
diff --git a/exts/pip.to_lorry b/exts/pip.to_lorry
index d537851..1027459 100755
--- a/exts/pip.to_lorry
+++ b/exts/pip.to_lorry
@@ -50,31 +50,19 @@ def find_repo_type(url):
tempdir = tempfile.mkdtemp()
p = subprocess.Popen([vcs, vcs_command, url], stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, stdin=subprocess.PIPE,
+ stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
cwd=tempdir)
# We close stdin on parent side to prevent the child from blocking
# if it reads on stdin
p.stdin.close()
- poll = select.poll()
+ while True:
+ line = p.stdout.readline()
+ if line == '':
+ break
- fdmap = {p.stdout.fileno(): p.stdout, p.stderr.fileno(): p.stderr}
- poll.register(p.stdout)
- poll.register(p.stderr)
-
- # Multiplex stdout and stderr
- # TODO: replace this by setting stderr=stdout
- while fdmap != {}:
- fds = poll.poll()
-
- for (fd, _) in fds:
- line = fdmap[fd].readline().rstrip()
- if line == '':
- poll.unregister(fd)
- del fdmap[fd]
- else:
- logging.debug('%s' % line)
+ logging.debug(line.rstrip())
p.wait() # even with eof on both streams, we still wait