Ejemplo n.º 1
0
    def publish(self, data_block):
        """
        Publish data

        :type data_block: :obj:`~datablock.DataBlock`
        :arg data_block: data block

        """
        self.logger.debug("in AWSGenericPublisher publish")
        if not self._consumes:
            return
        data = data_block[list(self._consumes.keys())[0]]
        if self.graphite_host and self.publish_to_graphite:
            end_point = graphite.Graphite(host=self.graphite_host,
                                          pickle_port=self.graphite_port,
                                          logger=self.logger)
            end_point.send_dict(
                self.graphite_context(data)[0],
                self.graphite_context(data)[1],
                debug_print=False,
                send_data=True,
                max_retries=self.max_retries,
                retry_interval=self.retry_interval,
            )
        csv_data = data.to_csv(self.output_file, index=False)
        if not self.output_file:
            print(csv_data)
    def publish(self, data_block):
        """
        Publish data

        :type data_block: :obj:`~datablock.DataBlock`
        :arg data_block: data block

        """
        if not self._consumes:
            return
        product = list(self._consumes.keys())[0]
        try:
            data = data_block[product]
        except KeyError:
            logging.getLogger().error(
                f"Failed to extract {product} from data block.")
            return
        if self.graphite_host and self.publish_to_graphite:
            end_point = graphite.Graphite(host=self.graphite_host,
                                          pickle_port=self.graphite_port)
            end_point.send_dict(self.graphite_context(data)[0],
                                self.graphite_context(data)[1],
                                debug_print=False,
                                send_data=True)
        if not self.output_file:
            logging.getLogger().debug(
                data.to_csv(self.output_file, index=False))
    def publish(self, data_block):
        """
        Publish data

        :type data_block: :obj:`~datablock.DataBlock`
        :arg data_block: data block

        """
        self.logger.debug("in Graphite GenericPublisher publish")
        if not self._consumes:
            return
        product = list(self._consumes.keys())[0]
        try:
            data = data_block[product]
        except KeyError:
            self.logger.exception(
                f"Failed to extract {product} from data block.")
            return
        if self.graphite_host and self.publish_to_graphite:
            end_point = graphite.Graphite(host=self.graphite_host,
                                          pickle_port=self.graphite_port,
                                          logger=self.logger)
            end_point.send_dict(
                self.graphite_context(data)[0],
                self.graphite_context(data)[1],
                debug_print=False,
                send_data=True,
                max_retries=self.max_retries,
                retry_interval=self.retry_interval,
            )
        if not self.output_file:
            self.logger.debug(data.to_csv(self.output_file, index=False))
Ejemplo n.º 4
0
    def publish(self, data_block):
        """
        Publish data

        :type data_block: :obj:`~datablock.DataBlock`
        :arg data_block: data block

        """
        if not self.consumes():
            return
        data = data_block[self.consumes()[0]]
        if self.graphite_host and self.publush_to_graphite:
            end_point = graphite.Graphite(host=self.graphite_host, pickle_port=self.graphite_port)
            end_point.send_dict(self.graphite_context(data)[0], self.graphite_context(data)[1], debug_print=False, send_data=True)
        csv_data = data.to_csv(self.output_file, index=False)
        if not self.output_file:
            print csv_data