diff --git a/Dockerfile b/Dockerfile index 9b67408..94b27b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,4 +18,4 @@ WORKDIR "/app" COPY . . -CMD ["./main.py"] +ENTRYPOINT ["./main.py"] diff --git a/card.py b/card.py index 3309de7..c591ec6 100644 --- a/card.py +++ b/card.py @@ -66,7 +66,11 @@ class Card: # download and resize card image def get_image(self, resolution): - response = requests.get(self._iurl) + try: + response = requests.get(self._iurl) + except: + return False + im = Image.open(BytesIO(response.content)) im = im.convert("RGB") im = im.resize(resolution, Image.BICUBIC) diff --git a/main.py b/main.py index 26e515f..8ffaab5 100755 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 import argparse import json diff --git a/opus.py b/opus.py index 3f60e0b..fe45932 100644 --- a/opus.py +++ b/opus.py @@ -27,9 +27,12 @@ class imageLoader(threading.Thread): # take next card i, card = self.__queue.get() - # fetch card image - logger.info("get image for card {}".format(card)) - im = card.get_image(self.__resolution) + # fetch card image (retry on fail) + while True: + logger.info("get image for card {}".format(card)) + im = card.get_image(self.__resolution) + if im: + break # paste image in correct position self.__lock.acquire()