Esempio n. 1
0
    def __data_timer_cb(self, timer):
        value = self.get_temperature()

        print("current temperature: {} ℃".format(value))

        try:
            self.__publish_data(value)
        except OSError as ose:
            err_msg = str(ose)

            if err_msg == "-1":
                pass
            elif err_msg == "[Errno 113] EHOSTUNREACH":
                Utilities.hard_reset()
            else:
                Utilities.log(self.__data_timer_cb, err_msg,
                              self.__log_callback)
        except Exception as e:
            err_msg = str(e)
            Utilities.log(self.__data_timer_cb, err_msg, self.__log_callback)
Esempio n. 2
0
    def __msg_timer_cb(self):
        while self.__starting:
            try:
                self.__mqtt_client.wait_msg()
            except OSError as ose:
                err_msg = str(ose)

                if err_msg == "-1":
                    pass
                elif err_msg == "[Errno 113] EHOSTUNREACH":
                    Utilities.hard_reset()
                else:
                    Utilities.log(self.__msg_timer_cb, err_msg,
                                  self.__log_callback)
                    # raise OSError(err_msg)
            except Exception as e:
                err_msg = str(e)
                Utilities.log(self.__msg_timer_cb, err_msg,
                              self.__log_callback)

            gc.collect()