Skip to content

Commit

Permalink
v4.0.4 prepare (#47)
Browse files Browse the repository at this point in the history
* upped timeouts, allowing for slower networks to connect to the WS server
* handle OctoPrint plugin update fetch error
* fixed wrong endpoint
* fix update loop
  • Loading branch information
AlbertMN authored Nov 29, 2022
1 parent 7fb8553 commit 7e3c7d4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion octoprint_simplyprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _before_send(event, hint):

sentry_sdk.init(
dsn="https://[email protected]/6611344",
traces_sample_rate=0.05,
traces_sample_rate=0.01,
before_send=_before_send,
release="SimplyPrint@{}".format(self._plugin_version)
)
Expand Down
8 changes: 4 additions & 4 deletions octoprint_simplyprint/websocket/file_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ def _download_sp_file(self, url: str, start: bool):
if pct != last_pct:
last_pct = pct
self._update_progress(pct)
except Exception:
except Exception as e:
self._logger.exception("Error downloading print")
self._loop.add_callback(
self.socket.send_sp, "file_progress",
{"state": "error", "message": "Network Error"}
{"state": "error", "message": "Network Error", "exception": e}
)
return
local = FileDestinations.LOCAL
Expand Down Expand Up @@ -178,11 +178,11 @@ def _download_sp_file(self, url: str, start: bool):
fparts = filename.split(".", 1)
ext = "gcode" if len(fparts) < 2 else fparts[-1]
filename = f"{fparts[0]}_copy{count}.{ext}"
except Exception:
except Exception as e:
self._logger.exception("Error locating file destination")
self._loop.add_callback(
self.socket.send_sp, "file_progress",
{"state": "error", "message": "Error processing download"}
{"state": "error", "message": "Error processing download", "exception": e}
)
return
else:
Expand Down
4 changes: 2 additions & 2 deletions octoprint_simplyprint/websocket/simplyprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ async def _connect(self) -> None:
if not reachable:
raise Exception("SimplyPrint not Reachable")
self.ws = await tornado.websocket.websocket_connect(
url, connect_timeout=5.
url, connect_timeout=15.
)
setattr(self.ws, "on_ping", self._on_ws_ping)
cur_time = self._monotonic()
Expand Down Expand Up @@ -1106,7 +1106,7 @@ async def _make_ai_request(self, endpoint, data, headers, timeout=10):
)

async def _post_snapshot(self, id: str = None, timer: float = None,
endpoint: str = "https://apirewrite.simplyprint.io/jobs/ReceiveSnapshot") -> None:
endpoint: str = "https://api.simplyprint.io/jobs/ReceiveSnapshot") -> None:
if id is not None:
img_data = await self._loop.run_in_executor(None, self.webcam_stream.extract_image)
data = {"id": id, "image": img_data}
Expand Down
9 changes: 6 additions & 3 deletions octoprint_simplyprint/websocket/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,15 @@ def check_software_update(self) -> List[Dict[str, Any]]:
url = f"http://127.0.0.1:{port}/plugin/softwareupdate/check"
try:
resp = requests.get(
url, headers={"X-Api-Key": api_key}, timeout=2.
url, headers={"X-Api-Key": api_key}, timeout=5
)
resp.raise_for_status()
if not 200 <= resp.status_code <= 210:
# Response code no good
self.logger.warning("Couldn't check for an OctoPrint update, API returned invalid response")
return []
ret: Dict[str, Any] = resp.json()
except Exception:
self.logger.exception("Error fetching OctoPrint Updates")
self.logger.warning("Error fetching OctoPrint Updates")
return []
updates: List[Dict[str, Any]] = []
uinfo: Dict[str, Any]
Expand Down
2 changes: 1 addition & 1 deletion octoprint_simplyprint/websocket/webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def extract_image(self) -> Optional[str]:
headers = {"Accept": "image/jpeg"}
try:
resp = requests.get(
self.url, headers=headers, verify=False, timeout=2
self.url, headers=headers, verify=False, timeout=4
)
resp.raise_for_status()
except Exception:
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.3"
plugin_version = "4.0.4"

# 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 7e3c7d4

Please sign in to comment.