Skip to content

Commit

Permalink
It turns out that being too smart will likely backfire
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Apr 8, 2024
1 parent 283eb83 commit 3e14848
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions moonraker_obico/printer_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,8 @@ def _start(self, steps_remaining):
self._process_unlinked_api_response(data)

except (IOError, OSError) as ex:
# trying to catch only network related errors here,
# all other errors must bubble up.

# http4xx can be an actionable bug, let it bubble up
if isinstance(ex, HTTPError):
status_code = ex.response.status_code
if 400 <= status_code < 500:
raise
# Should continue on error in case of temporary network problems
_logger.warning(ex)

steps_remaining -= 1
if steps_remaining < 0:
Expand All @@ -182,12 +176,12 @@ def stop(self):
pass

def announce_unlinked_status(self):
_logger.debug('printer_discovery calls server')
data = self._collect_device_info()

data['one_time_passcode'] = self.get_one_time_passcode()

endpoint = self.config.server.canonical_endpoint_prefix() + '/api/v1/octo/unlinked/'
_logger.debug(f'calling {endpoint}')
return requests.request('POST', endpoint, timeout=5, data=json.dumps(data), headers={'Content-Type': 'application/json'})

def _collect_device_info(self):
Expand Down

0 comments on commit 3e14848

Please sign in to comment.