kopia lustrzana https://github.com/jupyterhub/repo2docker
rodzic
f3505db967
commit
698f9e1196
|
@ -1,3 +1,4 @@
|
||||||
|
from functools import partial
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def execute_cmd(cmd, capture=False, **kwargs):
|
def execute_cmd(cmd, capture=False, **kwargs):
|
||||||
|
@ -15,10 +16,22 @@ def execute_cmd(cmd, capture=False, **kwargs):
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
raise subprocess.CalledProcessError(ret, cmd)
|
raise subprocess.CalledProcessError(ret, cmd)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
buf = []
|
||||||
|
def flush():
|
||||||
|
line = b''.join(buf).decode('utf8', 'replace')
|
||||||
|
buf[:] = []
|
||||||
|
return line
|
||||||
|
|
||||||
|
c_last = ''
|
||||||
try:
|
try:
|
||||||
for line in iter(proc.stdout.readline, b''):
|
for c in iter(partial(proc.stdout.read, 1), b''):
|
||||||
yield line.decode('utf8', 'replace')
|
if c_last == b'\r' and buf and c != b'\n':
|
||||||
|
yield flush()
|
||||||
|
buf.append(c)
|
||||||
|
if c == b'\n':
|
||||||
|
yield flush()
|
||||||
|
c_last = c
|
||||||
finally:
|
finally:
|
||||||
ret = proc.wait()
|
ret = proc.wait()
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
|
|
Ładowanie…
Reference in New Issue