Commit 75bf9c6f by John Jarvis

Separate function for send_to_xqueue

parent 0735e5ba
......@@ -122,14 +122,7 @@ class XQueueCertInterface(object):
}
key = cert.key
xheader = make_xheader(
'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')
self.__send_to_xqueue(contents, key)
cert.save()
return cert_status
......@@ -174,12 +167,7 @@ class XQueueCertInterface(object):
}
key = cert.key
xheader = make_xheader(
'http://{0}/certificate'.format(settings.SITE_NAME),
key, 'test-pull')
(error, msg) = self.xqueue_interface.send_to_queue(header=xheader,
body=json.dumps(contents))
self.__send_to_xqueue(contents, key)
cert.save()
return cert_status
......@@ -231,6 +219,16 @@ class XQueueCertInterface(object):
'course_id': course_id,
'name': profile.name,
}
self.__send_to_xqueue(contents, key)
cert.save()
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')
......@@ -238,8 +236,5 @@ class XQueueCertInterface(object):
(error, msg) = self.xqueue_interface.send_to_queue(
header=xheader, body=json.dumps(contents))
if error:
logger.critical('Unable to post results to qserver')
logger.critical('Unable to add a request to the queue')
raise Exception('Unable to send queue message')
cert.save()
return cert_status
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