diff --git a/.gitattributes b/.gitattributes index daa0d11f273ad1d3590ed9a63ac779a68128493e..9755cb69a44914c37eb184be1d3f69d8bdf72699 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1617,6 +1617,7 @@ LCS/Messaging/python/messaging/CMakeLists.txt -text LCS/Messaging/python/messaging/RPC.py -text LCS/Messaging/python/messaging/Service.py -text LCS/Messaging/python/messaging/__init__.py -text +LCS/Messaging/python/messaging/config.py -text LCS/Messaging/python/messaging/exceptions.py -text LCS/Messaging/python/messaging/messagebus.py -text LCS/Messaging/python/messaging/messages.py -text diff --git a/LCS/Messaging/python/messaging/CMakeLists.txt b/LCS/Messaging/python/messaging/CMakeLists.txt index 7dc82934b1c00d523d4c9008d4aa14ead76a1e8e..07133a8b9fdcfaa45fddf7cce267ed24e19d780c 100644 --- a/LCS/Messaging/python/messaging/CMakeLists.txt +++ b/LCS/Messaging/python/messaging/CMakeLists.txt @@ -11,6 +11,7 @@ include(PythonInstall) set(_py_files __init__.py + config.py exceptions.py messagebus.py messages.py diff --git a/LCS/Messaging/python/messaging/Service.py b/LCS/Messaging/python/messaging/Service.py index ca3269b829c3a64c936dcb58821700c4d44df6ef..0440d91f6a99c8397794c584f066315ad3ee8b95 100644 --- a/LCS/Messaging/python/messaging/Service.py +++ b/LCS/Messaging/python/messaging/Service.py @@ -122,7 +122,7 @@ class Service(AbstractBusListener): # then we need to listen to <servicename>.# if use_service_methods: subject = self.service_name + ".#" - else + else: subject = self.service_name # TODO: Create queue "address" diff --git a/LCS/Messaging/python/messaging/__init__.py b/LCS/Messaging/python/messaging/__init__.py index e0535559e7b62a258c8b9b9f8581117aa19f8cad..5a0ec953feebdaad37126cae2f5cb5226dbfa84c 100644 --- a/LCS/Messaging/python/messaging/__init__.py +++ b/LCS/Messaging/python/messaging/__init__.py @@ -24,25 +24,16 @@ Module initialization file. """ +from .config import * from .exceptions import * from .messages import * from .messagebus import * from .RPC import * from .Service import * import logging -from lofar.common import isProductionEnvironment, isTestEnvironment def setQpidLogLevel(qpidLogLevel): for name, logger in list(logging.Logger.manager.loggerDict.items()): if name.startswith('qpid.') and isinstance(logger, logging.Logger): logger.setLevel(qpidLogLevel) -def adaptNameToEnvironment(name): - if isProductionEnvironment(): - return name #return original name only for PRODUCTION LOFARENV - - if isTestEnvironment(): - return 'test.%s' % name #return 'test.' prefixed name only for TEST LOFARENV - - # in all other cases prefix queue/bus name with 'devel.' - return 'devel.%s' % name diff --git a/LCS/Messaging/python/messaging/config.py b/LCS/Messaging/python/messaging/config.py new file mode 100644 index 0000000000000000000000000000000000000000..106cce1cc58a5b5774e5e6976283162f5fb19922 --- /dev/null +++ b/LCS/Messaging/python/messaging/config.py @@ -0,0 +1,22 @@ +from lofar.common import isProductionEnvironment, isTestEnvironment + +def adaptNameToEnvironment(name): + if isProductionEnvironment(): + return name #return original name only for PRODUCTION LOFARENV + + if isTestEnvironment(): + return 'test.%s' % name #return 'test.' prefixed name only for TEST LOFARENV + + # in all other cases prefix queue/bus name with 'devel.' + return 'devel.%s' % name + +# Default settings for often used parameters. +if isProductionEnvironment(): + DEFAULT_BROKER = "scu001.control.lofar" +elif isTestEnvironment(): + DEFAULT_BROKER = "scu199.control.lofar" +else: # development environment + DEFAULT_BROKER = "localhost" + +# default exchange to use for all messages +DEFAULT_BUSNAME = adaptNameToEnvironment("lofar") diff --git a/LCS/Messaging/python/messaging/messagebus.py b/LCS/Messaging/python/messaging/messagebus.py index bfabad7f91497cef6f0a2b1e8a28efa6d8ca9af8..fd05be61aea7d94b2ecd216c27fea1aa6c0d5b2d 100644 --- a/LCS/Messaging/python/messaging/messagebus.py +++ b/LCS/Messaging/python/messaging/messagebus.py @@ -28,7 +28,7 @@ Provide an easy way exchange messages on the message bus. from lofar.messaging.exceptions import MessageBusError, MessageFactoryError from lofar.messaging.messages import to_qpid_message, MESSAGE_FACTORY -from lofar.messaging import adaptNameToEnvironment +from lofar.messaging.config import DEFAULT_BROKER, DEFAULT_BUSNAME from lofar.common.util import raise_exception, is_iterable from lofar.common.datetimeutils import to_milliseconds_since_unix_epoch, from_milliseconds_since_unix_epoch from lofar.common import isProductionEnvironment, isTestEnvironment @@ -45,17 +45,6 @@ from time import sleep logger = logging.getLogger(__name__) -# Default settings for often used parameters. -if isProductionEnvironment(): - DEFAULT_BROKER = "scu001.control.lofar" -elif isTestEnvironment(): - DEFAULT_BROKER = "scu199.control.lofar" -else: # development environment - DEFAULT_BROKER = "localhost" - -# default exchange to use for all messages -DEFAULT_BUSNAME = adaptNameToEnvironment("lofar") - DEFAULT_RECEIVER_CAPACITY = 1 DEFAULT_TIMEOUT = 5 diff --git a/MAC/Services/TBB/TBBClient/lib/tbbbuslistener.py b/MAC/Services/TBB/TBBClient/lib/tbbbuslistener.py index 5454bea0dc785fb7ec4191ae7d9b50b120198a56..9ec25b6590d64f9896dfb1d28a60fc6a821c4633 100644 --- a/MAC/Services/TBB/TBBClient/lib/tbbbuslistener.py +++ b/MAC/Services/TBB/TBBClient/lib/tbbbuslistener.py @@ -36,7 +36,7 @@ class TBBBusListener(AbstractBusListener): :param subjects: the subjects filter string to listen for. :param broker: valid Qpid broker host """ - super(TBBBusListener, self).__init__(address=busname, subject=DEFAULT_TBB_NOTIFICATION_PREFIX+"#", broker, **kwargs) + super(TBBBusListener, self).__init__(address=busname, subject=DEFAULT_TBB_NOTIFICATION_PREFIX+"#", broker=broker, **kwargs) def _handleMessage(self, msg): # try to handle an incoming message, and call the associated on<SomeMessage> method diff --git a/MAC/Services/src/PipelineControl.py b/MAC/Services/src/PipelineControl.py index e257974e2cb6cff049c6f597ac156ef0c0bc1ccb..b02f62f5f25bec3622bac6ab1e2901da76d995a3 100755 --- a/MAC/Services/src/PipelineControl.py +++ b/MAC/Services/src/PipelineControl.py @@ -329,7 +329,7 @@ class PipelineDependencies(object): return startable class PipelineControl(OTDBBusListener): - def __init__(self, busname=DEFAULT_BUSNAME, broker=DEFAULT_BROKER) + def __init__(self, busname=DEFAULT_BUSNAME, broker=DEFAULT_BROKER): super(PipelineControl, self).__init__(busname=busname, broker=broker) logger.info('PipelineControl busname=%s', busname) diff --git a/QA/QA_Service/lib/QABusListener.py b/QA/QA_Service/lib/QABusListener.py index 9919f904c2f12120bf9da37145ca1b8446052766..82439da3bcb8e14500b4dd69f0c91fbde24749cd 100644 --- a/QA/QA_Service/lib/QABusListener.py +++ b/QA/QA_Service/lib/QABusListener.py @@ -46,7 +46,7 @@ class QABusListener(AbstractBusListener): numthreads= <int> Number of parallel threads processing messages (default: 1) verbose= <bool> Output extra logging over stdout (default: False) """ - super(QABusListener, self).__init__(address=busname, subject=DEFAULT_QA_NOTIFICATION_SUBJECT_PREFIX+"#", broker, **kwargs) + super(QABusListener, self).__init__(address=busname, subject=DEFAULT_QA_NOTIFICATION_SUBJECT_PREFIX+"#", broker=broker, **kwargs) def _handleMessage(self, msg): logger.debug("QABusListener.handleMessage: %s" %str(msg)) diff --git a/SAS/MoM/MoMQueryService/MoMQueryServiceServer/momqueryservice.py b/SAS/MoM/MoMQueryService/MoMQueryServiceServer/momqueryservice.py index c174a11077e2b409ba242d48ed0f4029732498f0..7d614da617771e027bb7386ee773edb49a25ab9e 100755 --- a/SAS/MoM/MoMQueryService/MoMQueryServiceServer/momqueryservice.py +++ b/SAS/MoM/MoMQueryService/MoMQueryServiceServer/momqueryservice.py @@ -1486,7 +1486,6 @@ def main(): help='Address of the qpid broker, default: %default') parser.add_option("-b", "--busname", dest="busname", type="string", default=DEFAULT_BUSNAME, help="Name of the bus exchange on the qpid broker, [default: %default]") - help="Name for this service, [default: %default]") parser.add_option_group(dbcredentials.options_group(parser)) parser.set_defaults(dbcredentials="MoM") (options, args) = parser.parse_args() diff --git a/SAS/OTDB_Services/OTDBBusListener.py b/SAS/OTDB_Services/OTDBBusListener.py index 96129e0b56d670b405a804ee9c8afbdbb2fceb18..a6a501e76950476ffc95b99338f1f90be0b5c6ec 100644 --- a/SAS/OTDB_Services/OTDBBusListener.py +++ b/SAS/OTDB_Services/OTDBBusListener.py @@ -50,7 +50,7 @@ class OTDBBusListener(AbstractBusListener): numthreads= <int> Number of parallel threads processing messages (default: 1) verbose= <bool> Output extra logging over stdout (default: False) """ - super(OTDBBusListener, self).__init__(address=busname, subject=DEFAULT_OTDB_NOTIFICATION_SUBJECT, broker, **kwargs) + super(OTDBBusListener, self).__init__(address=busname, subject=DEFAULT_OTDB_NOTIFICATION_SUBJECT, broker=broker, **kwargs) def _handleMessage(self, msg): logger.debug("OTDBBusListener.handleMessage: %s" %str(msg)) diff --git a/SAS/ResourceAssignment/RATaskSpecifiedService/lib/RABusListener.py b/SAS/ResourceAssignment/RATaskSpecifiedService/lib/RABusListener.py index 829055dfe84249075039b3bb8955b014836bd87c..3977a3175b0f861df6944927deb24067ed8a66ed 100644 --- a/SAS/ResourceAssignment/RATaskSpecifiedService/lib/RABusListener.py +++ b/SAS/ResourceAssignment/RATaskSpecifiedService/lib/RABusListener.py @@ -52,7 +52,7 @@ class RATaskSpecifiedBusListener(AbstractBusListener): numthreads= <int> Number of parallel threads processing messages (default: 1) verbose= <bool> Output extra logging over stdout (default: False) """ - super(RATaskSpecifiedBusListener, self).__init__(address=busname, subject=DEFAULT_RA_TASK_SPECIFIED_NOTIFICATION_SUBJECT, broker, **kwargs) + super(RATaskSpecifiedBusListener, self).__init__(address=busname, subject=DEFAULT_RA_TASK_SPECIFIED_NOTIFICATION_SUBJECT, broker=broker, **kwargs) def _handleMessage(self, msg): logger.debug("RABusListener.handleMessage: %s" %str(msg)) diff --git a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py index f3c090d014dff087d35e28a820ce59382e6e1502..6766435b6d85d20345922caad81b03085065a514 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py +++ b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py @@ -52,7 +52,7 @@ class RADBBusListener(AbstractBusListener): verbose= <bool> Output extra logging over stdout (default: False) """ - super(RADBBusListener, self).__init__(address=busname, subject=DEFAULT_NOTIFICATION_PREFIX+"#", broker, **kwargs) + super(RADBBusListener, self).__init__(address=busname, subject=DEFAULT_NOTIFICATION_PREFIX+"#", broker=broker, **kwargs) def _handleMessage(self, msg): diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/changeshandler.py b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/changeshandler.py index 7bdb331f1cded53f081597c1328242cca5ae25ac..33bf4afcdc0bccb2a9cc69189d143f8ec79400b0 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/changeshandler.py +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/changeshandler.py @@ -52,7 +52,7 @@ CHANGE_DELETE_TYPE = 'delete' CHANGE_EVENT_TYPE = 'event' class ChangesHandler: - def __init__(self, busname=DEFAULT_BUSNAME + def __init__(self, busname=DEFAULT_BUSNAME, broker=DEFAULT_BROKER, momqueryrpc=None, radbrpc=None, sqrpc=None, **kwargs): """ ChangesHandler listens on the lofar notification message bus and keeps track of all the change notifications. diff --git a/SAS/SpecificationServices/lib/translation_service_rpc.py b/SAS/SpecificationServices/lib/translation_service_rpc.py index dda87435b95202e5ad7a5405558d4bab8ee2c70d..a23ea36a9da2729d683d3fe532bfd6fb338c2ac4 100644 --- a/SAS/SpecificationServices/lib/translation_service_rpc.py +++ b/SAS/SpecificationServices/lib/translation_service_rpc.py @@ -8,7 +8,7 @@ logger = logging.getLogger(__file__) class TranslationRPC(RPCWrapper): - def __init__(self, busname=DEFAULT_BUSNAME + def __init__(self, busname=DEFAULT_BUSNAME, broker=DEFAULT_BROKER, timeout=120): super(TranslationRPC, self).__init__(busname, SPECIFICATIONTRANSLATION_SERVICENAME, broker, timeout=timeout)