Ejemplo n.º 1
0
    def download_data(self, draw_graph=True):
        """
        Download data callback. Gets data from API/Db

        :type draw_graph: Bool
        """
        if self.mode == self.MODE_STATION:
            sensors = self.selected_sensors[self.current_station]
            try:
                data = self.data_manager.get_data_by_sensor_ids_for_graphing(
                    sensors)
                if draw_graph:
                    station_name = self.data_manager.get_station_name_by_id(
                        self.current_station)
                    GraphDrawer.draw_station_graph(station_name, data)
            except DataManagerError as e:
                self.logger.exception(e)
                self.show_exception_box(e)
        else:
            stations = self.selected_stations[self.current_param]
            try:
                data = self.data_manager.get_data_by_station_ids_for_graphing(
                    stations, self.current_param)
            except DataManagerError as e:
                self.logger.exception(e)
                self.show_exception_box(e)
            if draw_graph:
                GraphDrawer.draw_sensor_graph(self.current_param, data)