Skip to content
Snippets Groups Projects
Commit ab5bc721 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

prevent polluting output by subprocesses

parent 1f1c5c54
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ def docker_mapped_port(cid, port, timeout_seconds=15): ...@@ -55,7 +55,7 @@ def docker_mapped_port(cid, port, timeout_seconds=15):
while time.time() - started < timeout_seconds: while time.time() - started < timeout_seconds:
try: try:
output = subprocess.check_output('docker port %s %s' % (cid, port), output = subprocess.check_output('docker port %s %s' % (cid, port),
stderr=_DEVNULL stderr=_DEVNULL,
shell=True) shell=True)
return int(output.split(':', 2)[1]) return int(output.split(':', 2)[1])
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
...@@ -85,7 +85,9 @@ def remove_image(image, skip_nonexistent=False, max_retries=10): ...@@ -85,7 +85,9 @@ def remove_image(image, skip_nonexistent=False, max_retries=10):
if skip_nonexistent and not image_exists(image): if skip_nonexistent and not image_exists(image):
return True return True
for attempt in range(0, max_retries): for attempt in range(0, max_retries):
if subprocess.call(['docker','rmi', '-f', image]) == 0: if subprocess.call(['docker','rmi', '-f', image],
stdout=_DEVNULL,
stderr=subprocess.STDOUT) == 0:
return True return True
time.sleep(2) time.sleep(2)
print 'Failed to remove docker image %s' % image print 'Failed to remove docker image %s' % image
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment