From c339a163655cd35316f7b44982237c53ca603608 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 30 Aug 2020 09:03:34 +0200 Subject: [PATCH] small improvements in octoprint plugin * octoprint sometimes returns additional information a the 3d printer is offline. so, it's better to check if the octoprint job state starts with "Offline". * in case the returned job state is really long, truncate it. --- bumblebee_status/modules/contrib/octoprint.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bumblebee_status/modules/contrib/octoprint.py b/bumblebee_status/modules/contrib/octoprint.py index a324af2..a7ed8ac 100644 --- a/bumblebee_status/modules/contrib/octoprint.py +++ b/bumblebee_status/modules/contrib/octoprint.py @@ -85,8 +85,15 @@ class Module(core.module.Module): core.input.register(self, button=core.input.LEFT_MOUSE, cmd=self.__show_popup) def octoprint_status(self, widget): - if self.__octoprint_state == "Offline" or self.__octoprint_state == "Unknown": - return self.__octoprint_state + if ( + self.__octoprint_state.startswith("Offline") + or self.__octoprint_state == "Unknown" + ): + return ( + (self.__octoprint_state[:25] + "...") + if len(self.__octoprint_state) > 25 + else self.__octoprint_state + ) return ( self.__octoprint_state + " | B: "