Add more debugging info to taskbase call
This commit is contained in:
parent
5b3777cb87
commit
048fd1b4a7
|
|
@ -32,8 +32,14 @@ class TaskbaseClient:
|
|||
'password': self.password
|
||||
}
|
||||
response = requests.post('{}/api/login'.format(self.base_url), json=payload)
|
||||
if response.ok:
|
||||
data = response.json()
|
||||
self.token = data['accessToken']
|
||||
else:
|
||||
if response.status_code == 401:
|
||||
raise TaskbaseException('Unauthorized')
|
||||
else:
|
||||
raise TaskbaseException(f'Error Code: {response.status_code}')
|
||||
|
||||
def register_assignment(self, assignment):
|
||||
if self.token is None:
|
||||
|
|
@ -43,7 +49,7 @@ class TaskbaseClient:
|
|||
payload = {'type': 'SPELL_CHECK'}
|
||||
# we first need to register the assignment via API, so we get an ID
|
||||
response = requests.post('{}/api/task'.format(self.base_url), json=payload, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.ok:
|
||||
data = response.json()
|
||||
assignment.taskbase_id = data['id']
|
||||
assignment.save()
|
||||
|
|
@ -61,10 +67,10 @@ class TaskbaseClient:
|
|||
response = requests.post('{}/api/task/{}'.format(self.base_url, assignment.taskbase_id), json=payload,
|
||||
headers=headers)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise TaskbaseException('Something went wrong')
|
||||
if not response.ok:
|
||||
raise TaskbaseException(f'Something went wrong - {response.status_code}: {response.reason} - {response.text}')
|
||||
else: # todo: define what to do here
|
||||
raise TaskbaseException('Something went wrong')
|
||||
raise TaskbaseException(f'Something went wrong - {response.status_code}: {response.reason} - {response.text}')
|
||||
|
||||
def spellcheck(self, task, text):
|
||||
if self.token is None:
|
||||
|
|
|
|||
Loading…
Reference in New Issue