diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | inbox_for_todoist.widget/.DS_Store | bin | 0 -> 6148 bytes | |||
-rw-r--r-- | inbox_for_todoist.widget/online.py | 19 | ||||
-rw-r--r-- | inbox_for_todoist.widget/test.txt | bin | 0 -> 54451 bytes | |||
-rw-r--r-- | inbox_for_todoist.widget/todoist.cache | bin | 0 -> 6 bytes | |||
-rw-r--r-- | inbox_for_todoist.widget/todoistinbox.py | 69 |
6 files changed, 71 insertions, 19 deletions
@@ -2,7 +2,7 @@ ## An Übersicht widget for your Todoist Inbox ## --- ## About ## -Inbox for [Todoist](https://en.todoist.com/tour) is a simple Übersicht widget designed to present your todoist inbox on your Desktop. It is in no way affiliated with the Brand Todoist or Doist in any way nor is it addiliated with [Übersicht](http://tracesof.net/uebersicht/) or [Felix Hageloh](https://github.com/felixhageloh) +Inbox for [Todoist](https://en.todoist.com/tour) is a simple Übersicht widget designed to present your todoist inbox on your Desktop. It is in no way affiliated with the Brand Todoist or Doist in any way nor is it affiliated with [Übersicht](http://tracesof.net/uebersicht/) or [Felix Hageloh](https://github.com/felixhageloh) Below is a preview of what Inbox for Todoist can look like: diff --git a/inbox_for_todoist.widget/.DS_Store b/inbox_for_todoist.widget/.DS_Store Binary files differnew file mode 100644 index 0000000..5008ddf --- /dev/null +++ b/inbox_for_todoist.widget/.DS_Store diff --git a/inbox_for_todoist.widget/online.py b/inbox_for_todoist.widget/online.py new file mode 100644 index 0000000..6fb471b --- /dev/null +++ b/inbox_for_todoist.widget/online.py @@ -0,0 +1,19 @@ +# -*-coding:utf-8 -* +from urllib.error import URLError +import urllib.request + +def main(): + loop_value = 0 + while loop_value < 5: + try: + urllib.request.urlopen("http://www.google.com") + loop_value = 6 # Loops ends, cant +1 up to 6, online must be true + except URLError as e: + loop_value += 1 # Loops ends, all attempts are out, online must be false + if loop_value == 6: + return(True) + else: + return(False) + +if __name__ == '__main__': + main() diff --git a/inbox_for_todoist.widget/test.txt b/inbox_for_todoist.widget/test.txt Binary files differnew file mode 100644 index 0000000..af53bc2 --- /dev/null +++ b/inbox_for_todoist.widget/test.txt diff --git a/inbox_for_todoist.widget/todoist.cache b/inbox_for_todoist.widget/todoist.cache Binary files differnew file mode 100644 index 0000000..482c0e3 --- /dev/null +++ b/inbox_for_todoist.widget/todoist.cache diff --git a/inbox_for_todoist.widget/todoistinbox.py b/inbox_for_todoist.widget/todoistinbox.py index 0cd9554..52443bc 100644 --- a/inbox_for_todoist.widget/todoistinbox.py +++ b/inbox_for_todoist.widget/todoistinbox.py @@ -1,21 +1,54 @@ # -*-coding:utf-8 -* -def main(token='___YOUR TODOIST TOKEN HERE:___'): - from todoist.api import TodoistAPI - api = TodoistAPI(token) - api.sync() # initial sync - rank = 0 - for i in api.state['items']: #going through all the items in todoist - if i['project_id'] == 170911352: # if an item is in the inbox - if i['checked'] == 0: # if the item is incomplete - if i['priority'] == 1: - pri = "<p class='priority4'>" - elif i['priority'] == 2: - pri = "<p class='priority3'>" - elif i['priority'] == 3: - pri = "<p class='priority2'>" - elif i['priority'] == 4: - pri = "<p class='priority1'>" - rank += 1 - print(pri, "<b>", rank, '- </b>', i['content'], "</p>") # print name and id +import online +import pickle +import os + +def main(token='___YOUR TODOIST TOKEN HERE:___'): # FIXME: Remove personal token when comitting + if online.main() == False: + with open("todoist.cache", "rb") as myFile: + loaded_cache = pickle.load(myFile) + rank = 0 + for i in loaded_cache: #going through all the items in todoist + if i['project_id'] == 170911352: # if an item is in the inbox + if i['checked'] == 0: # if the item is incomplete + if i['priority'] == 1: + pri = "<p class='priority4'>" + elif i['priority'] == 2: + pri = "<p class='priority3'>" + elif i['priority'] == 3: + pri = "<p class='priority2'>" + elif i['priority'] == 4: + pri = "<p class='priority1'>" # FIXME: Color coding not working... + rank += 1 + print(pri, "<b>", rank, '- </b>', i['content'], "</p>") # print name and id + + + elif online.main() == True: + from todoist.api import TodoistAPI + api = TodoistAPI(token) + api.sync() # initial sync + + if os.path.exists("todoist.cache"): # Delete old cache + os.remove("todoist.cache") + open("todoist.cache", 'a').close() # Initialise new cache + # https://stackoverflow.com/questions/17322273/store-a-dictionary-in-a-file-for-later-retrieval + with open("todoist.cache", "wb") as myFile: + pickle.dump(api.state['items'], myFile) + + rank = 0 + for i in api.state['items']: #going through all the items in todoist + if i['project_id'] == 170911352: # if an item is in the inbox + if i['checked'] == 0: # if the item is incomplete + if i['priority'] == 1: + pri = "<p class='priority4'>" + elif i['priority'] == 2: + pri = "<p class='priority3'>" + elif i['priority'] == 3: + pri = "<p class='priority2'>" + elif i['priority'] == 4: + pri = "<p class='priority1'>" # FIXME: Color coding not working... + rank += 1 + print(pri, "<b>", rank, '- </b>', i['content'], "</p>") # print name and id + if __name__ == '__main__': main() |