Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

Commit 1bdc76a

Browse files
committed
codi: print the progress of docker pull operations to codi's stout
docker pull operations can take a long time depending on the size of the image. Print the progress of the pull operation on codi's stdout and return the complete log to the requestor. Signed-off-by: Todor Minchev <[email protected]>
1 parent 1bff3fe commit 1bdc76a

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

codi/codi.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,33 @@ def find_image(self):
7777
'''
7878
if request.method == 'GET':
7979
cli = dcrops.docker_connect(config.DOCKER_SOCKET)
80-
response = cli.search(request.args.get("image"))
81-
cli.close()
82-
return Response(json.dumps(response), mimetype='application/json')
80+
image = request.args.get("image")
81+
if image is not None:
82+
response = cli.search(image)
83+
cli.close()
84+
return Response(json.dumps(response), mimetype='application/json')
85+
else:
86+
cli.close()
87+
return "Error: Image not provided"
8388

8489
def pull_image(self):
8590
'''Download a toolchain image from Docker repository [GET]
8691
image: repo/image:tag
8792
returns: result of docker pull operation
8893
'''
8994
if request.method == 'GET':
95+
temp = ""
9096
cli = dcrops.docker_connect(config.DOCKER_SOCKET)
9197
image = request.args.get("image")
9298
if image is not None:
93-
response = cli.pull(image)
99+
for response in cli.pull(image, stream=True):
100+
print(response.decode("utf-8"))
101+
temp = temp + response.decode("utf-8")
94102
cli.close()
95-
return Response(json.dumps(response), mimetype='application/json')
103+
return Response(json.dumps(temp), mimetype='application/json')
96104
else:
97105
cli.close()
98-
return "Error: Image not found"
106+
return "Error: Image not provided"
99107

100108
def remove_image(self):
101109
'''Remove toolchain image from local store [GET]
@@ -111,7 +119,7 @@ def remove_image(self):
111119
return Response(json.dumps(response), mimetype='application/json')
112120
else:
113121
cli.close()
114-
return "Error: Image not found"
122+
return "Error: Image not provided"
115123

116124
def remove_toolchain(self):
117125
'''Remove toolchain from CODI database [GET]

setup.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""A setuptools based setup module.
22
33
See:
4-
https://github.com/todorez/crops
4+
https://github.com/crops/crops
55
"""
66

77
from setuptools import setup, find_packages
@@ -22,7 +22,7 @@
2222
long_description=long_description,
2323

2424
# The project's main homepage
25-
url='https://github.com/todorez/crops',
25+
url='https://github.com/crops/crops',
2626
author='Todor Minchev',
2727
author_email='[email protected]',
2828
license='GPLv3',
@@ -52,5 +52,4 @@
5252
# You can just specify the packages manually here if your project is
5353
# simple. Or you can use find_packages().
5454
packages=find_packages(exclude=['turff', 'codi']),
55-
5655
)

0 commit comments

Comments
 (0)