Skip to content

Commit

Permalink
Merge pull request #45 from crysxd/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
crysxd authored Dec 20, 2023
2 parents 5aa7783 + 627fd4d commit 74511d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Get OctoApp on Google Play!

[<img src="https://github.com/crysxd/OctoApp-Plugin/blob/1813c8145887d2862373a97279f56f4542c47ee3/images/play-badge.png" width="200">](https://play.google.com/store/apps/details?id=de.crysxd.octoapp&hl=en&gl=US) [<img src="https://github.com/crysxd/OctoApp-Plugin/blob/1813c8145887d2862373a97279f56f4542c47ee3/images/app-store-badge.png" width="200">](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
Expand All @@ -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

Expand Down
24 changes: 16 additions & 8 deletions moonraker_octoapp/moonrakerdatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand All @@ -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())
Expand All @@ -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())

Expand Down Expand Up @@ -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",
{
Expand All @@ -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)
1 change: 1 addition & 0 deletions octoapp/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 74511d5

Please sign in to comment.