From a7f3622e520b7667e3fc0e34f0ea57323ed3be13 Mon Sep 17 00:00:00 2001 From: Ace Date: Sat, 10 Feb 2024 22:43:57 +0100 Subject: [PATCH] fix tests --- inkycal/modules/inky_image.py | 2 +- inkycal/modules/inkycal_image.py | 2 +- inkycal/modules/inkycal_slideshow.py | 4 ++-- inkycal/modules/inkycal_webshot.py | 4 ++-- inkycal/modules/inkycal_xkcd.py | 8 ++++---- requirements.txt | 2 -- tests/test_inkycal_image.py | 2 +- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/inkycal/modules/inky_image.py b/inkycal/modules/inky_image.py index d259e71..67f4a14 100755 --- a/inkycal/modules/inky_image.py +++ b/inkycal/modules/inky_image.py @@ -255,7 +255,7 @@ def image_to_palette( else: logger.error("The given palette is unsupported.") - raise ValueError("The given palette is not supported.") + raise ValueError(f"The given palette ({palette}) is not supported.") if pal: # The palette needs to have 256 colors, for this, the black-colour diff --git a/inkycal/modules/inkycal_image.py b/inkycal/modules/inkycal_image.py index ea2a7a9..5387b9b 100755 --- a/inkycal/modules/inkycal_image.py +++ b/inkycal/modules/inkycal_image.py @@ -79,7 +79,7 @@ class Inkyimage(inkycal_module): im.resize(width=im_width, height=im_height) # convert images according to specified palette - im_black, im_colour = image_to_palette(image=im, palette=self.palette, dither=self.dither) + im_black, im_colour = image_to_palette(image=im.image.convert("RGB"), palette=self.palette, dither=self.dither) # with the images now send, clear the current image im.clear() diff --git a/inkycal/modules/inkycal_slideshow.py b/inkycal/modules/inkycal_slideshow.py index afd4f94..c7481fa 100755 --- a/inkycal/modules/inkycal_slideshow.py +++ b/inkycal/modules/inkycal_slideshow.py @@ -6,7 +6,7 @@ import glob from inkycal.custom import * # PIL has a class named Image, use alias for Inkyimage -> Images -from inkycal.modules.inky_image import Inkyimage as Images +from inkycal.modules.inky_image import Inkyimage as Images, image_to_palette from inkycal.modules.template import inkycal_module logger = logging.getLogger(__name__) @@ -118,7 +118,7 @@ class Slideshow(inkycal_module): im.resize(width=im_width, height=im_height) # convert images according to specified palette - im_black, im_colour = im.to_palette(self.palette) + im_black, im_colour = image_to_palette(im.image.convert("RGB"), self.palette) # with the images now send, clear the current image im.clear() diff --git a/inkycal/modules/inkycal_webshot.py b/inkycal/modules/inkycal_webshot.py index 20a3ce7..8d08cc6 100644 --- a/inkycal/modules/inkycal_webshot.py +++ b/inkycal/modules/inkycal_webshot.py @@ -6,7 +6,7 @@ by https://github.com/worstface from htmlwebshot import WebShot from inkycal.custom import * -from inkycal.modules.inky_image import Inkyimage as Images +from inkycal.modules.inky_image import Inkyimage as Images, image_to_palette from inkycal.modules.template import inkycal_module from tests import Config @@ -145,7 +145,7 @@ class Webshot(inkycal_module): im.resize(width=int(im.image.width * imageScale), height=webshotHeight) - im_webshot_black, im_webshot_colour = im.to_palette(self.palette) + im_webshot_black, im_webshot_colour = image_to_palette(im.image.convert("RGB"), self.palette) webshotCenterPosY = int((im_height / 2) - (im.image.height / 2)) diff --git a/inkycal/modules/inkycal_xkcd.py b/inkycal/modules/inkycal_xkcd.py index f486cca..b2ce25e 100644 --- a/inkycal/modules/inkycal_xkcd.py +++ b/inkycal/modules/inkycal_xkcd.py @@ -6,7 +6,7 @@ by https://github.com/worstface import xkcd from inkycal.custom import * -from inkycal.modules.inky_image import Inkyimage as Images +from inkycal.modules.inky_image import Inkyimage as Image2, image_to_palette from inkycal.modules.template import inkycal_module logger = logging.getLogger(__name__) @@ -24,7 +24,7 @@ class Xkcd(inkycal_module): "default": "latest" }, "palette": { - "label": "Which color palette should be used for the comic images?", + "label": "Which color palette should be used for the comic Image2?", "options": ["bw", "bwr", "bwy"] }, "alt": { @@ -149,7 +149,7 @@ class Xkcd(inkycal_module): comicSpaceBlack = Image.new('RGBA', (im_width, im_height), (255, 255, 255, 255)) comicSpaceColour = Image.new('RGBA', (im_width, im_height), (255, 255, 255, 255)) - im = Images() + im = Image2() im.load(f"{tmpPath}/xkcdComic.png") im.remove_alpha() @@ -170,7 +170,7 @@ class Xkcd(inkycal_module): im.resize(width=int(im.image.width * imageScale), height=comicHeight) - im_comic_black, im_comic_colour = im.to_palette(self.palette) + im_comic_black, im_comic_colour = image_to_palette(im.image.convert("RGB"), self.palette) headerCenterPosY = int((im_height / 2) - ((im.image.height + headerHeight + altHeight) / 2)) comicCenterPosY = int((im_height / 2) - ((im.image.height + headerHeight + altHeight) / 2) + headerHeight) diff --git a/requirements.txt b/requirements.txt index f2b6248..54f9e69 100644 --- a/requirements.txt +++ b/requirements.txt @@ -40,11 +40,9 @@ pytz==2023.3.post1 PyYAML==6.0.1 recurring-ical-events==2.1.1 requests==2.31.0 -RPi.GPIO==0.7.1 sgmllib3k==1.0.0 six==1.16.0 soupsieve==2.5 -spidev==3.5 todoist-api-python==2.1.3 types-python-dateutil==2.8.19.20240106 typing_extensions==4.8.0 diff --git a/tests/test_inkycal_image.py b/tests/test_inkycal_image.py index 4c1b24c..9e72b09 100755 --- a/tests/test_inkycal_image.py +++ b/tests/test_inkycal_image.py @@ -14,7 +14,7 @@ from tests import Config preview = Inkyimage.preview merge = Inkyimage.merge -url ="https://github.com/aceinnolab/Inkycal/blob/assets/tests/Inkycal_cover.png" +url ="https://raw.githubusercontent.com/aceinnolab/Inkycal/assets/tests/Inkycal_cover.png" im = Image.open(requests.get(url, stream=True).raw) im.save("test.png", "PNG")