async def handle_message(
            self,
            msg: core_pb2.CoreLocation) -> DataWrapper[core_pb2.Response]:
        response = DataWrapper(False, "location", core_pb2.Response())
        update = dap_update_pb2.DapUpdate()
        try:
            upd = update.update.add()
            upd.tablename = self._db_structure["table"]
            upd.fieldname = self._db_structure["field"]
            upd.key.core = msg.core_key
            upd.value.type = 9
            upd.value.l.CopyFrom(msg.location)
        except Exception as e:
            msg = "Failed to create dap_update proto from director location update: ", str(
                e)
            self.warning(msg)
            response.error_code = 500
            response.add_narrative(msg)

        try:
            status = self._dap_manager.update(update)
            response.success = status
        except Exception as e:
            msg = "DapManager: failed update: " + str(e)
            response.add_narrative(msg)
            self.warning(msg)

        return response
Beispiel #2
0
 async def handle_message(self, msg: Any) -> DataWrapper[Any]:
     response = DataWrapper(False, "", None)
     try:
         if isinstance(msg, dap_interface_pb2.NoInputParameter):
             proto = self._dap_call()
         else:
             proto = self._dap_call(msg)
         response.success = True
         response.data = proto
     except Exception as e:
         error = dap_interface_pb2.Successfulness()
         error.success = False
         error.errorcode = 503
         error.narrative.append(str(e))
         self.exception("Exception during DAP call: ", e)
         response.error_code = 503
         response.add_narrative(str(e))
         response.data = error
     return response