From 4cea3be7f48f1ce84d1ec8bd096b203d9fc7bddc Mon Sep 17 00:00:00 2001 From: nlef <52351624+nlef@users.noreply.github.com> Date: Wed, 24 Nov 2021 22:42:12 +0300 Subject: [PATCH] fix max lapse duration fps --- bot/camera.py | 2 +- bot/klippy.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bot/camera.py b/bot/camera.py index 58cf8d2..08be3d0 100644 --- a/bot/camera.py +++ b/bot/camera.py @@ -338,7 +338,7 @@ def _calculate_fps(self, frames_count: int): fps = math.ceil(frames_count / self._min_lapse_duration) return fps if fps >= 1 else 1 elif actual_duration > self._max_lapse_duration > 0: - return math.ceil(frames_count / self._min_lapse_duration) + return math.ceil(frames_count / self._max_lapse_duration) def _create_timelapse(self, printing_filename: str, gcode_name: str, info_mess: Message) -> (BytesIO, BytesIO, int, int, str, str): while self.light_need_off: diff --git a/bot/klippy.py b/bot/klippy.py index 4f82d98..c5ac7e4 100644 --- a/bot/klippy.py +++ b/bot/klippy.py @@ -157,8 +157,9 @@ def check_connection(self) -> str: try: response = requests.get(f"http://{self._host}/printer/info", headers=self._headers, timeout=2) return '' if response.ok else f"Connection failed. {response.reason}" - except Exception: - return 'f"Connection failed.' + except Exception as ex: + logger.error(ex, exc_info=True) + return f"Connection failed." @staticmethod def sensor_message(sensor: str, sens_key: str, response) -> str: