Commit 5529eecb by John Jarvis Committed by Carlos Andrés Rocha

Separate function for send_to_xqueue

parent 5019e2d0
...@@ -122,14 +122,7 @@ class XQueueCertInterface(object): ...@@ -122,14 +122,7 @@ class XQueueCertInterface(object):
} }
key = cert.key key = cert.key
xheader = make_xheader( self.__send_to_xqueue(contents, key)
'http://{0}/certificate'.format(settings.SITE_NAME),
key, 'test-pull')
(error, msg) = self.xqueue_interface.send_to_queue(
header=xheader, body=json.dumps(contents))
if error:
logger.critical('Unable to add a request to the queue')
raise Exception('Unable to send queue message')
cert.save() cert.save()
return cert_status return cert_status
...@@ -174,12 +167,7 @@ class XQueueCertInterface(object): ...@@ -174,12 +167,7 @@ class XQueueCertInterface(object):
} }
key = cert.key key = cert.key
xheader = make_xheader( self.__send_to_xqueue(contents, key)
'http://{0}/certificate'.format(settings.SITE_NAME),
key, 'test-pull')
(error, msg) = self.xqueue_interface.send_to_queue(header=xheader,
body=json.dumps(contents))
cert.save() cert.save()
return cert_status return cert_status
...@@ -231,15 +219,22 @@ class XQueueCertInterface(object): ...@@ -231,15 +219,22 @@ class XQueueCertInterface(object):
'course_id': course_id, 'course_id': course_id,
'name': profile.name, 'name': profile.name,
} }
xheader = make_xheader(
'http://{0}/update_certificate?{1}'.format( self.__send_to_xqueue(contents, key)
key, settings.SITE_NAME), key, 'test-pull')
(error, msg) = self.xqueue_interface.send_to_queue(
header=xheader, body=json.dumps(contents))
if error:
logger.critical('Unable to post results to qserver')
raise Exception('Unable to send queue message')
cert.save() cert.save()
return cert_status return cert_status
def __send_to_xqueue(self, contents, key):
# TODO - need to read queue name from settings
xheader = make_xheader(
'http://{0}/update_certificate?{1}'.format(
key, settings.SITE_NAME), key, 'test-pull')
(error, msg) = self.xqueue_interface.send_to_queue(
header=xheader, body=json.dumps(contents))
if error:
logger.critical('Unable to add a request to the queue')
raise Exception('Unable to send queue message')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment