Skip to content

Commit

Permalink
Workaround for image pulling under MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed May 15, 2023
1 parent c70f7a9 commit 19b380d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions riptide_engine_docker/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import docker
import json
import platform
from json import JSONDecodeError
from typing import Tuple, Dict, Union, List, Optional

Expand Down Expand Up @@ -207,15 +208,22 @@ def create_named_volume(self, name: str) -> None:

def __pull_image(self, image_name, line_reset, update_func):
try:
# TODO: This is pretty messy and should just be entirely redone, not
# relying on the direct outout of the stream as-is.
for line in self.client.api.pull(image_name, stream=True):
try:
status = json.loads(line)
if "progress" in status:
update = status["status"] + " : " + status[ "progress"]
else:
update = status["status"]
except JSONDecodeError:
update = line
# On other OSes the API doesn't really seem to behave nicely,
# returning invalid or incomplete JSON
if platform.system() == "Linux":
try:
status = json.loads(line)
if "progress" in status:
update = status["status"] + " : " + status[ "progress"]
else:
update = status["status"]
except JSONDecodeError:
update = line
else:
update = "Pulling image..."
update_func(f"{line_reset} {update}")
update_func(f"{line_reset} Done!\n")
except APIError as ex:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.7.6'
__version__ = '0.7.7'
from glob import glob
from setuptools import setup, find_packages

Expand Down

0 comments on commit 19b380d

Please sign in to comment.