diff --git a/README.md b/README.md index 1bf80b1..46c084a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Get OctoApp on Google Play! [](https://play.google.com/store/apps/details?id=de.crysxd.octoapp&hl=en&gl=US) [](https://apps.apple.com/us/app/octoapp-for-octoprint/id1658133862) -## Setup +## Setup OctoPrint 1. Open your **OctoPrint web interface** 2. Open the **settings** using the 🔧 (wrench) icon in the top right @@ -23,6 +23,15 @@ Get OctoApp on Google Play! The app will automatically register itself with the plugin the next time you use the app. In the OctoPrint settings, you will find a list with all connected devices. + +## Setup Moonraker + +1. Open a terminal on your Klipper host via SSH +2. Run `/bin/bash -c \"$(curl -fsSL https://octoapp.eu/install.sh)\"` +This will clone this repository and guide your through the setup process + +The app will automatically register itself with the plugin the next time you use the app. The plugin will run as a Linux service in the background, you can start or stop it via Mainsail or Fluidd. To see a list of registered apps open http://_yourmoonraker_/server/database/item?namespace=octoapp + ## Configuration Nothing to configure! OctoApp will connect automatically to the plugin diff --git a/moonraker_octoapp/moonrakerdatabase.py b/moonraker_octoapp/moonrakerdatabase.py index 740aa30..527c888 100644 --- a/moonraker_octoapp/moonrakerdatabase.py +++ b/moonraker_octoapp/moonrakerdatabase.py @@ -20,7 +20,7 @@ def __init__(self, printerId:str, pluginVersion:str) -> None: def GetAppsEntry(self): - Sentry.Info("Database", "Getting apps") + Sentry.Debug("Database", "Getting apps") result = MoonrakerClient.Get().SendJsonRpcRequest("server.database.get_item", { "namespace": "octoapp", @@ -56,10 +56,10 @@ def GetPrinterName(self) -> str: if fluiddResult.HasError() is False and mainsailResult.GetResult() is not None: return mainsailResult.GetResult()["value"] - if mainsailResult.HasError() is False & mainsailResult.GetErrorCode() != 404 or mainsailResult.GetErrorCode() != -3260: + if mainsailResult.HasError() is True and mainsailResult.GetErrorCode() != 404 and mainsailResult.GetErrorCode() != -3260: Sentry.Error("Database", "Failed to load Mainsail printer name"+mainsailResult.GetLoggingErrorStr()) - if fluiddResult.HasError() is False & fluiddResult.GetErrorCode() != 404 or fluiddResult.GetErrorCode() != -3260: + if fluiddResult.HasError() is True and fluiddResult.GetErrorCode() != 404 and fluiddResult.GetErrorCode() != -3260: Sentry.Error("Database", "Failed to load Fluidd printer name"+fluiddResult.GetLoggingErrorStr()) return "Klipper" @@ -69,10 +69,12 @@ def GetOrCreateEncryptionKey(self): if self.CachedEncryptionKey is None: result = MoonrakerClient.Get().SendJsonRpcRequest("server.database.get_item", { - "namespace": "ocotapp", + "namespace": "octoapp", "key": "public.encryptionKey", }) - if result.HasError() is False and result.GetResult() is not None: + if result.HasError() is True & result.GetErrorCode() == 404 or result.GetErrorCode() != -3260: + Sentry.Warn("Database", "Encryption key not yet created") + elif result.HasError() is False and result.GetResult() is not None: self.CachedEncryptionKey = result.GetResult()["value"] else: raise Exception("Failed to get encryption key %s" % result.GetErrorStr()) @@ -82,11 +84,11 @@ def GetOrCreateEncryptionKey(self): Sentry.Info("Database", "Created new encryption key") result = MoonrakerClient.Get().SendJsonRpcRequest("server.database.post_item", { - "namespace": "ocotapp", + "namespace": "octoapp", "key": "public.encryptionKey", "value": self.CachedEncryptionKey }) - if result.HasError() is False and result.GetResult() is not None: + if result.HasError() is True: # Just log. Should be flushed over time. Sentry.Error("Database", "Failed to set encryption key %s" % result.GetErrorStr()) @@ -142,8 +144,14 @@ def _continuouslyAnnouncePresence(self): t.start() def _doContinuouslyAnnouncePresence(self): + Sentry.Info("Database", "Starting continuous update") while True: try: + if MoonrakerClient.Get() is None: + Sentry.Info("Database", "Connection not ready...") + time.sleep(5) + continue + Sentry.Info("Database", "Updating presence") result = MoonrakerClient.Get().SendJsonRpcRequest("server.database.post_item", { @@ -164,4 +172,4 @@ def _doContinuouslyAnnouncePresence(self): time.sleep(300) except Exception as e: Sentry.ExceptionNoSend("Failed to update presence", e) - time.sleep(60) + time.sleep(30) diff --git a/octoapp/sentry.py b/octoapp/sentry.py index eb996bc..12e9e35 100644 --- a/octoapp/sentry.py +++ b/octoapp/sentry.py @@ -119,6 +119,7 @@ def Exception(msg, exception): # Only logs an exception, without reporting. @staticmethod def ExceptionNoSend(msg, exception): + Sentry.Error("SENTRY", "Exception no send: %s" % exception) Sentry._handleException(msg, exception, False)