work around non confirmity of the web services

This commit is contained in:
Benjamin Dauvergne 2012-11-06 16:40:23 +01:00
parent 483a66aa89
commit 76e8041ef1
1 changed files with 4 additions and 4 deletions

View File

@ -38,7 +38,7 @@ class BlackboardConnector(object):
def _get_course_helper(self, r):
r.encoding = 'utf-8'
if r.status_code == 200:
if r.status_code == 200 and r.content.startswith('<'):
try:
x = etree.XML(r.content)
except etree.ParseError:
@ -59,7 +59,7 @@ class BlackboardConnector(object):
courses.append(course)
return True, CourseByOwnerResponse(info_message_elt.text.strip(),
courses)
elif r.status_code == 400:
elif r.status_code in (200,400):
return False, r.text
else:
logging.error('BlackBoard code HTTP %s', r.status_code)
@ -127,7 +127,7 @@ class BlackboardConnector(object):
def get_categories(self):
r = self.send_request('GetCategories')
if r.status_code == 200:
if r.status_code == 200 and r.content.startswith('<'):
x = etree.XML(r.content)
info_message_elt = x.find('infoMessage')
category_elts = x.findall('categories/category')
@ -140,7 +140,7 @@ class BlackboardConnector(object):
categories.append(category)
return True, GetCategoryResponse(info_message_elt.text.strip(),
categories)
elif r.status_code == 400:
elif r.status_code in (200,400):
return False, r.text
else:
print r.text