Skip to content

Commit

Permalink
potential fix for switching endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii committed Dec 11, 2022
1 parent 238a609 commit e08efaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions octoprint_simplyprint/websocket/simplyprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,23 +658,22 @@ def _on_uninstall_finished(uninstall_success: asyncio.Future):
None, self.sys_manager.restart_octoprint
)
elif demand == "goto_ws_prod":
self.test = False
self._set_ws_url()
self._save_item("endpoint", "production")
self.close()
self._connect()
self._loop.add_callback(self._switch_ws_connection, "production")
elif demand == "goto_ws_test":
self.test = True
self._set_ws_url()
self._save_item("endpoint", "test")
self.close()
self._connect()
self._loop.add_callback(self._switch_ws_connection, "test")
elif demand == "send_logs":
if "token" in args:
self._loop.run_in_executor(None, self._send_requested_logs, args.get("token"), args.get("logs", []), args.get("max_body"))
else:
self._logger.debug(f"Unknown demand: {demand}")

def _switch_ws_connection(self, endpoint: str) -> None:
self._logger.debug(f"Switching to {endpoint} endpoint.")
self.test = (endpoint == "test")
self._set_ws_url()
self._save_item("endpoint", endpoint)
self.ws.close(1000, "Switching endpoint")

def _send_requested_logs(self, token: str, logs: list[str], max_size: int) -> None:
url = LOGS_UPLOAD_URL + self.settings.get(["printer_id"])
data = {"token": token}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
# Remember to bump the version in octoprint_simplyprint/__init__.py as well
plugin_version = "4.0.5dev1"
plugin_version = "4.0.5dev2"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit e08efaf

Please sign in to comment.