Skip to content
Snippets Groups Projects
Commit e78da1ba authored by Mattia Mancini's avatar Mattia Mancini
Browse files

SW-720: make the rpc opening the bus to send the message

parent 6e5fb9cf
No related branches found
No related tags found
1 merge request!6Import cobalt2 into lofar4
......@@ -55,7 +55,7 @@ from .validation_service_rpc import ValidationRPC
from .lofarxml_to_momxml_translator import LofarXmlToMomXmlTranslator
validationrpc = ValidationRPC.create(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER)
# Translation modes:
FULL_TRANSLATION = "Full translation"
......@@ -64,6 +64,7 @@ MODEL_TRANSLATION = "Model translation"
class SpecificationTranslationHandler(ServiceMessageHandler):
def __init__(self):
super().__init__()
self.validationrpc = ValidationRPC.create(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER)
def trigger_to_specification(self, trigger_spec, trigger_id, job_priority):
......@@ -103,8 +104,8 @@ class SpecificationTranslationHandler(ServiceMessageHandler):
raise
logger.debug("specification after translation from trigger -> " + specification_xml)
response = validationrpc.validate_specification(specification_xml)
with self.validationrpc:
response = validationrpc.validate_specification(specification_xml)
if response["valid"]:
logger.info("Translation successful")
return {"specification": specification_xml}
......@@ -137,7 +138,8 @@ class SpecificationTranslationHandler(ServiceMessageHandler):
raise
logger.debug("MoM spec after translation -> " + momspec_xml.decode("utf-8"))
response = validationrpc.validate_mom_specification(momspec_xml)
with self.validationrpc:
response = validationrpc.validate_mom_specification(momspec_xml)
if response["valid"]:
logger.info("Translation successful")
return {"mom-specification": momspec_xml}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment