Improved some code logic to better support new web-ui
This commit is contained in:
parent
c5aa200b80
commit
5327d12f0e
@ -66,13 +66,18 @@ class Agenda(inkycal_module):
|
|||||||
self.date_format = config['date_format']
|
self.date_format = config['date_format']
|
||||||
self.time_format = config['time_format']
|
self.time_format = config['time_format']
|
||||||
self.language = config['language']
|
self.language = config['language']
|
||||||
self.ical_urls = config['ical_urls'].split(',')
|
|
||||||
|
|
||||||
# Check if ical_files is an empty string
|
# Check if ical_files is an empty string
|
||||||
if config['ical_files'] != "":
|
if config['ical_urls']:
|
||||||
|
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']:
|
||||||
self.ical_files = config['ical_files'].split(',')
|
self.ical_files = config['ical_files'].split(',')
|
||||||
else:
|
else:
|
||||||
self.ical_files = []
|
self.ical_files = config['ical_files']
|
||||||
|
|
||||||
# Additional config
|
# Additional config
|
||||||
self.timezone = get_system_tz()
|
self.timezone = get_system_tz()
|
||||||
|
@ -65,20 +65,20 @@ class Calendar(inkycal_module):
|
|||||||
|
|
||||||
# optional parameters
|
# optional parameters
|
||||||
self.weekstart = config['week_starts_on']
|
self.weekstart = config['week_starts_on']
|
||||||
self.show_events = bool(config['show_events'])
|
self.show_events = config['show_events']
|
||||||
self.date_format = config["date_format"]
|
self.date_format = config["date_format"]
|
||||||
self.time_format = config['time_format']
|
self.time_format = config['time_format']
|
||||||
self.language = config['language']
|
self.language = config['language']
|
||||||
|
|
||||||
if config['ical_urls'] != "":
|
if config['ical_urls']:
|
||||||
self.ical_urls = config['ical_urls'].split(',')
|
self.ical_urls = config['ical_urls'].split(',')
|
||||||
else:
|
else:
|
||||||
self.ical_urls = []
|
self.ical_urls = config['ical_urls']
|
||||||
|
|
||||||
if config['ical_files'] != "":
|
if config['ical_files']:
|
||||||
self.ical_files = config['ical_files'].split(',')
|
self.ical_files = config['ical_files'].split(',')
|
||||||
else:
|
else:
|
||||||
self.ical_files = []
|
self.ical_files = config['ical_files']
|
||||||
|
|
||||||
# additional configuration
|
# additional configuration
|
||||||
self.timezone = get_system_tz()
|
self.timezone = get_system_tz()
|
||||||
@ -117,7 +117,7 @@ class Calendar(inkycal_module):
|
|||||||
logger.debug(f'events-section size: {im_width} x {events_height} px')
|
logger.debug(f'events-section size: {im_width} x {events_height} px')
|
||||||
else:
|
else:
|
||||||
logger.debug("Not allocating space for events")
|
logger.debug("Not allocating space for events")
|
||||||
calendar_height = im_height - month_name_height - weekday_height
|
calendar_height = im_height - month_name_height - weekdays_height
|
||||||
logger.debug(f'calendar-section size: {im_width} x {calendar_height} px')
|
logger.debug(f'calendar-section size: {im_width} x {calendar_height} px')
|
||||||
|
|
||||||
# Create a 7x6 grid and calculate icon sizes
|
# Create a 7x6 grid and calculate icon sizes
|
||||||
|
@ -60,7 +60,7 @@ class Feeds(inkycal_module):
|
|||||||
self.feed_urls = self.config["feed_urls"].split(",")
|
self.feed_urls = self.config["feed_urls"].split(",")
|
||||||
|
|
||||||
# optional parameters
|
# optional parameters
|
||||||
self.shuffle_feeds = bool(self.config["shuffle_feeds"])
|
self.shuffle_feeds = self.config["shuffle_feeds"]
|
||||||
|
|
||||||
# give an OK message
|
# give an OK message
|
||||||
print('{0} loaded'.format(filename))
|
print('{0} loaded'.format(filename))
|
||||||
|
@ -1,30 +1,47 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from inkycal.modules import Feeds as Module
|
from inkycal.modules import Feeds as Module
|
||||||
|
|
||||||
test = {
|
tests = [
|
||||||
|
{
|
||||||
"position": 1,
|
"position": 1,
|
||||||
"name": "Feeds",
|
"name": "Feeds",
|
||||||
"config": {
|
"config": {
|
||||||
"size": [400,100],
|
"size": [400,100],
|
||||||
"feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#",
|
"feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#",
|
||||||
"shuffle_feeds": "True",
|
"shuffle_feeds": True,
|
||||||
"padding_x": 10,
|
"padding_x": 10,
|
||||||
"padding_y": 10,
|
"padding_y": 10,
|
||||||
"fontsize": 12,
|
"fontsize": 12,
|
||||||
"language": "en"
|
"language": "en"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"position": 1,
|
||||||
|
"name": "Feeds",
|
||||||
|
"config": {
|
||||||
|
"size": [400,100],
|
||||||
|
"feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#",
|
||||||
|
"shuffle_feeds": False,
|
||||||
|
"padding_x": 10,
|
||||||
|
"padding_y": 10,
|
||||||
|
"fontsize": 12,
|
||||||
|
"language": "en"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
module = Module(test)
|
|
||||||
|
|
||||||
class module_test(unittest.TestCase):
|
class module_test(unittest.TestCase):
|
||||||
def test_get_config(self):
|
def test_get_config(self):
|
||||||
print('getting data for web-ui')
|
print('getting data for web-ui...', end = "")
|
||||||
module.get_config()
|
Module.get_config()
|
||||||
|
print('OK')
|
||||||
|
|
||||||
def test_generate_image(self):
|
def test_generate_image(self):
|
||||||
print('testing image generation')
|
for test in tests:
|
||||||
module.generate_image()
|
print(f'test {tests.index(test)+1} generating image..')
|
||||||
|
module = Module(test)
|
||||||
|
module.generate_image()
|
||||||
|
print('OK')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user