'module' object has no attribute 'TodoistAPI'
not sure if anyone can help me here with the error below
INFO:root:Configuration Complete
DEBUG:root:Todo API: TODOIST
EXCEPTION IN PROGRAM ==================================
'module' object has no attribute 'TodoistAPI'
<type 'exceptions.AttributeError'>
<traceback object at 0xb557d5f8>
END EXCEPTION =========================================
DEBUG:root:DRIVER: ENTERING FOR LOOP
^CError in sys.excepthook:
Traceback (most recent call last):
File "infowindow.py", line 51, in HandleException
iw.display(rotation)
File "/home/pi/1y/mod_infowindow/infowindow.py", line 80, in display
self.epd.display_frame(self.epd.get_frame_buffer(self.image))
File "/home/pi/1y/driver/epd7in5b.py", line 196, in display_frame
self.send_data(temp2)
File "/home/pi/1y/driver/epd7in5b.py", line 102, in send_data
epdif.spi_transfer([data])
File "/home/pi/1y/driver/epdif.py", line 50, in spi_transfer
SPI.writebytes(data)
KeyboardInterrupt
Original exception was:
Traceback (most recent call last):
File "infowindow.py", line 176, in
main()
File "infowindow.py", line 58, in main
todo = modTodo.ToDo(todo_opts)
File "/home/pi/1y/mod_todo/mod_todoist.py", line 8, in init
self.api = todoist.TodoistAPI(opts['api_key'])
AttributeError: 'module' object has no attribute 'TodoistAPI'
I did not change anything to mod_todoist.py not sure if I need to replace the api_key to my own API token in the file, but I have put my own API token in the config.json
This is caused by the use of the deprecated todoist pip library. The project needs to be updated to use the todoist-api-python library instead.
This endpoint is deprecated.
If you're reading this on a browser, there's a good chance you can change
the v8 part on the URL to v9 and get away with it. ;)
If you're using the API directly, please update your use case to rely
on the new API endpoints, available under /sync/v9/ or /rest/v2/ prefixes.
For more details, please see documentation at
https://developer.todoist.com/guides/#our-apis
Here's a simple diff that seems to work (once you install the todoist-api-python library):
diff --git a/mod_todo/mod_todoist.py b/mod_todo/mod_todoist.py
index c0b74ff..2e8606d 100644
--- a/mod_todo/mod_todoist.py
+++ b/mod_todo/mod_todoist.py
@@ -1,27 +1,27 @@
-import todoist
+from todoist_api_python.api import TodoistAPI
import logging
class ToDo:
def __init__(self, opts):
logging.debug("Todo API: TODOIST")
- self.api = False
+ self.api = None
if not opts['api_key']:
logging.warning("Not loading Todo API, since no api key is configured")
else:
- self.api = todoist.TodoistAPI(opts['api_key'])
- self.api.sync()
+ self.api = TodoistAPI(opts['api_key'])
def list(self):
items = []
# Loop through original array from Todoist and pull out
# items of interest
- if self.api:
- for item in self.api.state['items']:
- if item['checked'] == 0:
+ tasks = self.api.get_tasks()
+ if tasks:
+ for item in tasks:
+ if not item.is_completed:
items.append({
- "content": item['content'],
- "priority": item['priority'],
+ "content": item.content,
+ "priority": item.priority,
})
# Sort the array by priority