From afe84dc8e67b169cbaaf7a82a8fb8491e2a2c273 Mon Sep 17 00:00:00 2001 From: Ace Date: Sat, 21 Nov 2020 16:22:15 +0100 Subject: [PATCH] Improved web-ui labels, improved logging, improved support for testing Switched from NotoSans-SemiCondensed to NotoSansUI-Regular --- inkycal/modules/ical_parser.py | 1 - inkycal/modules/inkycal_agenda.py | 7 +++---- inkycal/modules/inkycal_calendar.py | 7 +++---- inkycal/modules/inkycal_feeds.py | 8 +++++--- inkycal/modules/inkycal_image.py | 3 +-- inkycal/modules/inkycal_jokes.py | 3 ++- inkycal/modules/inkycal_server.py | 3 +-- inkycal/modules/inkycal_todoist.py | 3 +-- inkycal/modules/inkycal_weather.py | 5 +---- inkycal/modules/template.py | 7 +------ 10 files changed, 18 insertions(+), 29 deletions(-) diff --git a/inkycal/modules/ical_parser.py b/inkycal/modules/ical_parser.py index 143e6fe..6186e97 100644 --- a/inkycal/modules/ical_parser.py +++ b/inkycal/modules/ical_parser.py @@ -34,7 +34,6 @@ except ModuleNotFoundError: filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class iCalendar: """iCalendar parsing moudule for inkycal. diff --git a/inkycal/modules/inkycal_agenda.py b/inkycal/modules/inkycal_agenda.py index 3afb3c3..169911d 100644 --- a/inkycal/modules/inkycal_agenda.py +++ b/inkycal/modules/inkycal_agenda.py @@ -14,14 +14,13 @@ import arrow filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Agenda(inkycal_module): """Agenda class Create agenda and show events from given icalendars """ - name = "Inkycal Agenda" + name = "Agenda - Display upcoming events from given iCalendars" requires = { "ical_urls" : { @@ -68,13 +67,13 @@ class Agenda(inkycal_module): self.language = config['language'] # Check if ical_files is an empty string - if config['ical_urls']: + if config['ical_urls'] and isinstance(config['ical_urls'], str): self.ical_urls = config['ical_urls'].split(',') else: self.ical_urls = config['ical_urls'] # Check if ical_files is an empty string - if config['ical_files']: + if config['ical_files'] and isinstance(config['ical_files'], str): self.ical_files = config['ical_files'].split(',') else: self.ical_files = config['ical_files'] diff --git a/inkycal/modules/inkycal_calendar.py b/inkycal/modules/inkycal_calendar.py index 9f1bfa4..c3c1858 100644 --- a/inkycal/modules/inkycal_calendar.py +++ b/inkycal/modules/inkycal_calendar.py @@ -12,14 +12,13 @@ import arrow filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Calendar(inkycal_module): """Calendar class Create monthly calendar and show events from given icalendars """ - name = "Inkycal Calendar" + name = "Calendar - Show monthly calendar with events from iCalendars" optional = { @@ -70,12 +69,12 @@ class Calendar(inkycal_module): self.time_format = config['time_format'] self.language = config['language'] - if config['ical_urls']: + if config['ical_urls'] and isinstance(config['ical_urls'], str): self.ical_urls = config['ical_urls'].split(',') else: self.ical_urls = config['ical_urls'] - if config['ical_files']: + if config['ical_files'] and isinstance(config['ical_files'], str): self.ical_files = config['ical_files'].split(',') else: self.ical_files = config['ical_files'] diff --git a/inkycal/modules/inkycal_feeds.py b/inkycal/modules/inkycal_feeds.py index 961f4dc..393252d 100644 --- a/inkycal/modules/inkycal_feeds.py +++ b/inkycal/modules/inkycal_feeds.py @@ -18,14 +18,13 @@ except ImportError: filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Feeds(inkycal_module): """RSS class parses rss/atom feeds from given urls """ - name = "Inkycal RSS / Atom" + name = "RSS / Atom - Display feeds from given RSS/ATOM feeds" requires = { "feed_urls" : { @@ -57,7 +56,10 @@ class Feeds(inkycal_module): raise Exception('config is missing {}'.format(param)) # required parameters - self.feed_urls = config["feed_urls"].split(",") + if config["feed_urls"] and isinstance(config['feed_urls'], str): + self.feed_urls = config["feed_urls"].split(",") + else: + self.feed_urls = config["feed_urls"] # optional parameters self.shuffle_feeds = config["shuffle_feeds"] diff --git a/inkycal/modules/inkycal_image.py b/inkycal/modules/inkycal_image.py index 448b2b7..b5f8729 100644 --- a/inkycal/modules/inkycal_image.py +++ b/inkycal/modules/inkycal_image.py @@ -15,7 +15,6 @@ import numpy filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Inkyimage(inkycal_module): """Image class @@ -26,7 +25,7 @@ class Inkyimage(inkycal_module): requires = { 'path': { - "label":"Please enter the path of the image file (local or URL)", + "label":"Please enter the full path of the image file (local or URL)", } } diff --git a/inkycal/modules/inkycal_jokes.py b/inkycal/modules/inkycal_jokes.py index 196a531..339a3da 100644 --- a/inkycal/modules/inkycal_jokes.py +++ b/inkycal/modules/inkycal_jokes.py @@ -11,10 +11,11 @@ from inkycal.modules.template import inkycal_module from inkycal.custom import * import requests +# Show less logging for request module +logging.getLogger("urllib3").setLevel(logging.WARNING) filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Jokes(inkycal_module): """Icanhazdad-api class diff --git a/inkycal/modules/inkycal_server.py b/inkycal/modules/inkycal_server.py index fa17e11..5776ff2 100644 --- a/inkycal/modules/inkycal_server.py +++ b/inkycal/modules/inkycal_server.py @@ -14,13 +14,12 @@ import requests filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Inkyserver(inkycal_module): """Inkyserver class""" - name = "Inkycal Server" + name = "Inkycal Server - get image from Inkycal server" requires = { "panel_id" : { diff --git a/inkycal/modules/inkycal_todoist.py b/inkycal/modules/inkycal_todoist.py index 4d9dad8..116d136 100644 --- a/inkycal/modules/inkycal_todoist.py +++ b/inkycal/modules/inkycal_todoist.py @@ -17,14 +17,13 @@ except ImportError: filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Todoist(inkycal_module): """Todoist api class parses todo's from api-key """ - name = "Inkycal Todoist" + name = "Todoist API - show your todos from todoist" requires = { 'api_key': { diff --git a/inkycal/modules/inkycal_weather.py b/inkycal/modules/inkycal_weather.py index 5df6d19..09827a8 100644 --- a/inkycal/modules/inkycal_weather.py +++ b/inkycal/modules/inkycal_weather.py @@ -20,15 +20,12 @@ except ImportError: filename = os.path.basename(__file__).split('.py')[0] logger = logging.getLogger(filename) -logger.setLevel(level=logging.ERROR) class Weather(inkycal_module): """Weather class parses weather details from openweathermap """ - #TODO: automatic setup of pyowm by location id if location is numeric - - name = "Inkycal Weather (openweathermap)" + name = "Weather (openweathermap) - Get weather forecasts from openweathermap" requires = { diff --git a/inkycal/modules/template.py b/inkycal/modules/template.py index f46be8d..87ebd0d 100644 --- a/inkycal/modules/template.py +++ b/inkycal/modules/template.py @@ -1,11 +1,6 @@ import abc from inkycal.custom import * - -# Set the root logger to level DEBUG to allow any inkycal module to use the -# logger for any level -logging.basicConfig(level = logging.DEBUG) - class inkycal_module(metaclass=abc.ABCMeta): """Generic base class for inykcal modules""" @@ -28,7 +23,7 @@ class inkycal_module(metaclass=abc.ABCMeta): self.fontsize = conf["fontsize"] self.font = ImageFont.truetype( - fonts['NotoSans-SemiCondensed'], size = self.fontsize) + fonts['NotoSansUI-Regular'], size = self.fontsize) def set(self, help=False, **kwargs): """Set attributes of class, e.g. class.set(key=value)