def convey_string(self): try: list = [] for item in self.data: if item['observation'] == 'cows_aggressivity': # harcoding para poner cows_aggressivity a = 'irrigation' else: a = item['observation'] if a not in sensor_types.ObservationType._NAMES_TO_VALUES.keys(): logger.info("No esta en la lista") raise errors.NoObservationTypeException() list.append(dss_types.ResponseString(Timestamp=int(item["timestamp"]), Observation=sensor_types.ObservationType._NAMES_TO_VALUES[a], Units=item["units"], Result= item["result"])) self.trans_sender.open() self.client_sender.sendDssResultString(int(self.request_id), int(self.algorithm_id), list) self.trans_sender.close() logger.info("[THRIFT CLIENT] String conveyed to MMT from algorithm_id {} with request_id {} and data {}".format(self.algorithm_id, self.request_id, list)) except errors.NoObservationTypeException as e: logger.info("[THRIFT CLIENT] Observation type do not exist") raise e except Exception as e: logger.info("[THRIFT CLIENT] {}".format(e)) raise e
def convey_string(self): try: list = [] for item in self.data: if item["observation"] not in sensor_type.ObservationType._NAMES_TO_VALUES.keys(): raise errors.NoObservationTypeException() list.append(dss_types.ResponseNumber(Timestamp=int(item["timestamp"]), Observation=sensor_types.ObservationType._NAMES_TO_VALUES[item["observation"]], Units=item["units"], Result= str(item["result"]))) self.trans_sender.open() self.client_sender.sendDssResultString(int(self.request_id), int(self.algorithm_id), list) self.trans_sender.close() logger.info("[THRIFT CLIENT] String conveyed to MMT from algorithm_id {} with request_id {} and data {}".format(self.algorithm_id, self.request_id, list)) except errors.NoObservationTypeException: logger.info("[THRIFT CLIENT] Observation type do not exist") except Exception as e: logger.info("[THRIFT CLIENT] {}".format(e))