checkpoint
This commit is contained in:
@@ -23,16 +23,18 @@ from icons.weather_icons.weather_icons import get_weather_icon
|
||||
from inkycal.custom.functions import fonts
|
||||
from inkycal.custom.functions import get_system_tz
|
||||
from inkycal.custom.functions import internet_available
|
||||
from inkycal.custom.functions import top_level
|
||||
from inkycal.custom.inkycal_exceptions import NetworkNotReachableError
|
||||
from inkycal.custom.openweathermap_wrapper import OpenWeatherMap
|
||||
from inkycal.modules.inky_image import image_to_palette
|
||||
from inkycal.modules.template import inkycal_module
|
||||
from inkycal.settings import Settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
icons_dir = os.path.join(top_level, "icons", "ui-icons")
|
||||
settings = Settings()
|
||||
|
||||
icons_dir = os.path.join(settings.FONT_PATH, "ui-icons")
|
||||
|
||||
|
||||
def outline(image: Image, size: int, color: tuple) -> Image:
|
||||
@@ -139,7 +141,7 @@ class Fullweather(inkycal_module):
|
||||
|
||||
# Check if all required parameters are present
|
||||
for param in self.requires:
|
||||
if not param in config:
|
||||
if param not in config:
|
||||
raise Exception(f"config is missing {param}")
|
||||
|
||||
# required parameters
|
||||
|
@@ -8,13 +8,13 @@ from inkycal.custom import *
|
||||
# PIL has a class named Image, use alias for Inkyimage -> Images
|
||||
from inkycal.modules.inky_image import Inkyimage as Images, image_to_palette
|
||||
from inkycal.modules.template import inkycal_module
|
||||
from inkycal.utils.json_cache import JSONCache
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Slideshow(inkycal_module):
|
||||
"""Cycles through images in a local image folder
|
||||
"""
|
||||
"""Cycles through images in a local image folder"""
|
||||
name = "Slideshow - cycle through images from a local folder"
|
||||
|
||||
requires = {
|
||||
@@ -53,7 +53,7 @@ class Slideshow(inkycal_module):
|
||||
|
||||
# required parameters
|
||||
for param in self.requires:
|
||||
if not param in config:
|
||||
if param not in config:
|
||||
raise Exception(f'config is missing {param}')
|
||||
|
||||
# optional parameters
|
||||
@@ -64,14 +64,15 @@ class Slideshow(inkycal_module):
|
||||
|
||||
# Get the full path of all png/jpg/jpeg images in the given folder
|
||||
all_files = glob.glob(f'{self.path}/*')
|
||||
self.images = [i for i in all_files
|
||||
if i.split('.')[-1].lower() in ('jpg', 'jpeg', 'png')]
|
||||
self.images = [i for i in all_files if i.split('.')[-1].lower() in ('jpg', 'jpeg', 'png')]
|
||||
|
||||
if not self.images:
|
||||
logger.error('No images found in the given folder, please '
|
||||
'double check your path!')
|
||||
logger.error('No images found in the given folder, please double check your path!')
|
||||
raise Exception('No images found in the given folder path :/')
|
||||
|
||||
self.cache = JSONCache('inkycal_slideshow')
|
||||
self.cache_data = self.cache.read()
|
||||
|
||||
# set a 'first run' signal
|
||||
self._first_run = True
|
||||
|
||||
@@ -89,14 +90,16 @@ class Slideshow(inkycal_module):
|
||||
logger.info(f'Image size: {im_size}')
|
||||
|
||||
# rotates list items by 1 index
|
||||
def rotate(somelist):
|
||||
return somelist[1:] + somelist[:1]
|
||||
def rotate(list: list):
|
||||
return list[1:] + list[:1]
|
||||
|
||||
# Switch to the next image if this is not the first run
|
||||
if self._first_run:
|
||||
self._first_run = False
|
||||
self.cache_data["current_index"] = 0
|
||||
else:
|
||||
self.images = rotate(self.images)
|
||||
self.cache_data["current_index"] = (self.cache_data["current_index"] + 1) % len(self.images)
|
||||
|
||||
# initialize custom image class
|
||||
im = Images()
|
||||
@@ -110,7 +113,7 @@ class Slideshow(inkycal_module):
|
||||
# Remove background if present
|
||||
im.remove_alpha()
|
||||
|
||||
# if autoflip was enabled, flip the image
|
||||
# if auto-flip was enabled, flip the image
|
||||
if self.autoflip:
|
||||
im.autoflip(self.orientation)
|
||||
|
||||
@@ -123,6 +126,8 @@ class Slideshow(inkycal_module):
|
||||
# with the images now send, clear the current image
|
||||
im.clear()
|
||||
|
||||
self.cache.write(self.cache_data)
|
||||
|
||||
# return images
|
||||
return im_black, im_colour
|
||||
|
||||
|
@@ -11,6 +11,8 @@ from inkycal.modules.template import inkycal_module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
class Xkcd(inkycal_module):
|
||||
name = "xkcd - Displays comics from xkcd.com by Randall Munroe"
|
||||
@@ -57,7 +59,7 @@ class Xkcd(inkycal_module):
|
||||
"""Generate image for this module"""
|
||||
|
||||
# Create tmp path
|
||||
tmpPath = f"{top_level}/temp"
|
||||
tmpPath = settings.TEMPORARY_FOLDER
|
||||
|
||||
if not os.path.exists(tmpPath):
|
||||
os.mkdir(tmpPath)
|
||||
|
Reference in New Issue
Block a user