work around non confirmity of the web services (bis)

This commit is contained in:
Benjamin Dauvergne 2012-11-06 16:42:47 +01:00
parent cff0f0c0a4
commit 6bd60fbfe4
1 changed files with 1 additions and 13 deletions

View File

@ -28,22 +28,14 @@ class BlackboardConnector(object):
self.shared_key = shared_key
self.session = requests.session()
url = os.path.join(self.url, 'login/')
print url
self.session.post(url,
params=dict(user_id=self.login,
password=self.password, action='login'))
# print login
# print r.status_code
# print self.session.__dict__
def _get_course_helper(self, r):
r.encoding = 'utf-8'
if r.status_code == 200 and r.content.startswith('<'):
try:
x = etree.XML(r.content)
except etree.ParseError:
print 'Parse Error', r.content, r.status_code
raise
x = etree.XML(r.content)
info_message_elt = x.find('infoMessage')
course_elts = x.findall('*/course')
courses = []
@ -119,10 +111,7 @@ class BlackboardConnector(object):
url = os.path.join(self.url, 'ui-ui-Polynum-BBLEARN/app', request_name)
logging.debug('sending request %s', url)
r = getattr(self.session, method)(url, **kwargs)
print 'content', r.content
r.encoding = 'utf-8'
if r.status_code == 500:
print r.text
return r
def get_categories(self):
@ -143,7 +132,6 @@ class BlackboardConnector(object):
elif r.status_code in (200,400):
return False, r.text
else:
print r.text
logging.error('BlackBoard code HTTP %s', r.status_code)
return False, 'Erreur BlackBoard {0}'.format(r.status_code)