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.
This commit is contained in:
Bernhard B 2020-08-30 09:03:34 +02:00
parent 58bbcf2ac5
commit c339a16365

View file

@ -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: "