Beispiel #1
0
 def sendMessage(self, module_path, command_name, *args, **kwargs):
     message = IncomingMessage.fromData(
         command_id=RawMessageSender.getCommandId(),
         command_name=command_name,
         module_path=module_path,
         params=kwargs)
     return self._petition_handler.sendPetition(message)
Beispiel #2
0
 def addParticle(self, particle, **kwargs):
     message = IncomingMessage.fromData(command_id=Phenomena.getCommandId(),
                                        command_name="ADD",
                                        module_path="node",
                                        params={
                                            'particle_name': particle,
                                            'theta': kwargs.get('theta', 0),
                                            'phi': kwargs.get('phi', 0),
                                            'p': kwargs.get('p', None),
                                            'E': kwargs.get('E', None)
                                        })
     received_message = self._sendMessage(message)
     return received_message
Beispiel #3
0
 def _attendPetition(self, address, *args):
     try:
         split_modules_path = address[1:].split('/')
         module_path = ""
         command_name = ""
         params = {}
         #if(address.find("J/psi") != -1):
         #    module_path = "node"
         #    command_name = "ADD"
         #    params["particle_name"] = "J/psi"
         #elif split_modules_path[0] == "ADD":
         #    module_path = "node"
         #    command_name = "ADD"
         #    params["particle_name"] = split_modules_path[1]
         #elif split_modules_path[0] == "PURGE":
         #    module_path = "node.accumulator"
         #    command_name = "PURGE"
         if len(split_modules_path) == 1:
             if split_modules_path[0] == "ADD":
                 module_path = "node"
                 command_name = "ADD"
                 params["particle_name"] = args[0]
             elif split_modules_path[0] == "PURGE":
                 module_path = "node.accumulator"
                 command_name = "PURGE"
         else:
             command_name = split_modules_path[1]
             module_path = ".".join(split_modules_path[:-1])
             params = dict(zip(args[::2], args[1::2]))
         _id = params.pop("command_id", 0)
         new_message = IncomingMessage.fromData(command_id=_id,
                                                command_name=command_name,
                                                module_path=module_path,
                                                params=params)
         node = self._node_controller.findModule(new_message.module_path)
         node.execute(new_message)
         out_message = OutcomingMessage.okMessage(new_message,
                                                  new_message.params)
         self._log.info(out_message)
     except Exception as ex:
         exc_type, exc_obj, exc_tb = sys.exc_info()
         fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
         message = "Exception: Type: {0} Name: {1} Line: {2} Messsage: {3}".format(
             exc_type, fname, exc_tb.tb_lineno, str(ex))
         out_message = OutcomingMessage.errorMessage(new_message, message)
         self._log.exception(out_message)
Beispiel #4
0
 def addParticle(self, particle):
     message = IncomingMessage.fromData(command_id=Phenomena.getCommandId(), command_name="ADD", module_path="node", params={'particle_name': particle})
     received_message = self._sendMessage(message)
     return received_message