diff --git a/source/habitica.py b/source/habitica.py index 5aea506..f8ab082 100644 --- a/source/habitica.py +++ b/source/habitica.py @@ -7,8 +7,15 @@ def get_all_habtasks(auth): url = 'https://habitica.com/api/v3/tasks/user/' # TODO: handle error cases for response response = requests.get(url,headers=auth) - hab_raw = response.json() - hab_tasklist = hab_raw['data'] #FINALLY getting something I can work with... this will be a list of dicts I want to turn into a list of objects with class hab_tasks. Hrm. Weeeelll, if I make a class elsewhere.... + if response.ok == True: + hab_raw = response.json() + """FINALLY getting something I can work with... this will be a list of + dicts I want to turn into a list of objects with class hab_tasks. + Hrm. Weeeelll, if I make a class elsewhere....""" + hab_tasklist = hab_raw['data'] + else: + hab_tasklist = [] + print(response.reason) #keeping records of all our tasks hab_tasks = [] diff --git a/source/oneWaySync.py b/source/oneWaySync.py index 0e92606..ec69e01 100644 --- a/source/oneWaySync.py +++ b/source/oneWaySync.py @@ -110,6 +110,7 @@ def sync_todoist_to_habitica(): newDict = new_hab.task_dict r = main.write_hab_task(newDict) if r.ok == False: + #TODO: check ['errors'], due to it sometimes not having it errMsg = r.json()['errors'][0]['message'] alias = r.json()['errors'][0]['value'] print("Error Code "+str(r.status_code)+": \"" diff --git a/source/todo_task.py b/source/todo_task.py index 1bea5a1..d03eefe 100644 --- a/source/todo_task.py +++ b/source/todo_task.py @@ -115,19 +115,19 @@ def complete(self, status): @property #due date def due_date(self): - return self.__task_dict['due_date_utc'] + return self.__task_dict['due'] @due_date.setter def due_date(self, date): - self.__task_dict['due_date_utc'] = date + self.__task_dict['due'] = date @property #due date def due(self): from dateutil import parser import datetime - if self.__task_dict['due_date_utc'] != None: - date = parser.parse(self.__task_dict['due_date_utc']) + if self.__task_dict['due'] != None: + date = parser.parse(self.__task_dict['due']['date']) return date else: return '' @@ -141,7 +141,7 @@ def dueToday(self): import pytz today = datetime.utcnow().replace(tzinfo=pytz.UTC) try: - wobble = parser.parse(self.__task_dict['due_date_utc']) - timedelta(hours=6) #that datetime thing is pulling todoist's due dates to my time zone + wobble = parser.parse(self.__task_dict['due']) - timedelta(hours=6) #that datetime thing is pulling todoist's due dates to my time zone dueDate = wobble.date() except: dueDate = "" @@ -167,7 +167,7 @@ def dueLater(self): import pytz today = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC) try: - wobble = parser.parse(self.__task_dict['due_date_utc']) + wobble = parser.parse(self.__task_dict['due']) dueDate = wobble.date() except: dueDate = ""