Merge pull request #211 from aceisace/hotfix/todoist-module
- Fix an issue where the moduel woud crash if there were too many todos and not enough space to display them - Fix an issue where deleting a group containing todos would cause the modue to crash
This commit is contained in:
commit
e9b395bf99
@ -14,7 +14,7 @@
|
|||||||
<a href="https://github.com/aceisace/Inkycal"><img alt="python" src="https://img.shields.io/badge/python-%3E3.7-lightgrey"></a>
|
<a href="https://github.com/aceisace/Inkycal"><img alt="python" src="https://img.shields.io/badge/python-%3E3.7-lightgrey"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Inykcal is a software written in python for selected E-Paper displays. It converts these displays into useful information dashboards. It's open-source, free for personal use, fully modular and user-friendly. Despite all this, Inkycal can run well even on the Raspberry Pi Zero. Oh, and it's open for third-party modules! Hooray!
|
Inkycal is a software written in python for selected E-Paper displays. It converts these displays into useful information dashboards. It's open-source, free for personal use, fully modular and user-friendly. Despite all this, Inkycal can run well even on the Raspberry Pi Zero. Oh, and it's open for third-party modules! Hooray!
|
||||||
|
|
||||||
## Main features
|
## Main features
|
||||||
Inkycal is fully modular, you can mix and match any modules you like and configure them on the web-ui. For now, these following built-in modules are supported:
|
Inkycal is fully modular, you can mix and match any modules you like and configure them on the web-ui. For now, these following built-in modules are supported:
|
||||||
|
@ -136,11 +136,14 @@ class Todoist(inkycal_module):
|
|||||||
'name':task['content'],
|
'name':task['content'],
|
||||||
'due':task['due']['string'] if task['due'] != None else "",
|
'due':task['due']['string'] if task['due'] != None else "",
|
||||||
'priority':task['priority'],
|
'priority':task['priority'],
|
||||||
'project':all_projects[ task['project_id'] ]
|
'project':all_projects[ task['project_id' ] ] if task['project_id'] in all_projects else "deleted"
|
||||||
}
|
}
|
||||||
for task in tasks]
|
for task in tasks]
|
||||||
|
|
||||||
# logger.debug(f'simplified: {simplified}')
|
# remove groups that have been deleted
|
||||||
|
simplified = [task for task in simplified if task['project'] != "deleted"]
|
||||||
|
|
||||||
|
logger.debug(f'simplified: {simplified}')
|
||||||
|
|
||||||
# Get maximum width of project names for selected font
|
# Get maximum width of project names for selected font
|
||||||
project_width = int(max([
|
project_width = int(max([
|
||||||
@ -163,35 +166,36 @@ class Todoist(inkycal_module):
|
|||||||
# Add the parsed todos on the image
|
# Add the parsed todos on the image
|
||||||
cursor = 0
|
cursor = 0
|
||||||
for name, todos in grouped.items():
|
for name, todos in grouped.items():
|
||||||
if todos != []:
|
if todos:
|
||||||
for todo in todos:
|
for todo in todos:
|
||||||
line_x, line_y = line_positions[cursor]
|
if cursor < len(line_positions):
|
||||||
|
line_x, line_y = line_positions[cursor]
|
||||||
|
|
||||||
# Add todo project name
|
# Add todo project name
|
||||||
write(
|
write(
|
||||||
im_colour, line_positions[cursor],
|
im_colour, line_positions[cursor],
|
||||||
(project_width, line_height),
|
(project_width, line_height),
|
||||||
todo['project'], font=self.font, alignment='left')
|
todo['project'], font=self.font, alignment='left')
|
||||||
|
|
||||||
# Add todo due if not empty
|
# Add todo due if not empty
|
||||||
if todo['due'] != "":
|
if todo['due'] != "":
|
||||||
|
write(
|
||||||
|
im_black,
|
||||||
|
(line_x + project_width, line_y),
|
||||||
|
(due_width, line_height),
|
||||||
|
todo['due'], font=self.font, alignment='left')
|
||||||
|
|
||||||
|
# Add todo name
|
||||||
write(
|
write(
|
||||||
im_black,
|
im_black,
|
||||||
(line_x + project_width, line_y),
|
(line_x+project_width+due_width, line_y),
|
||||||
(due_width, line_height),
|
(im_width-project_width-due_width, line_height),
|
||||||
todo['due'], font=self.font, alignment='left')
|
todo['name'], font=self.font, alignment='left')
|
||||||
|
|
||||||
# Add todo name
|
cursor += 1
|
||||||
write(
|
else:
|
||||||
im_black,
|
logger.error('More todos than available lines')
|
||||||
(line_x+project_width+due_width, line_y),
|
break
|
||||||
(im_width-project_width-due_width, line_height),
|
|
||||||
todo['name'], font=self.font, alignment='left')
|
|
||||||
|
|
||||||
cursor += 1
|
|
||||||
if cursor > max_lines:
|
|
||||||
logger.error('More todos than available lines')
|
|
||||||
break
|
|
||||||
|
|
||||||
# return the images ready for the display
|
# return the images ready for the display
|
||||||
return im_black, im_colour
|
return im_black, im_colour
|
||||||
|
Loading…
Reference in New Issue
Block a user