Skip to content

Commit

Permalink
https://sentry.obico.io/organizations/sentry/issues/12008/?project=8&…
Browse files Browse the repository at this point in the history
…query=is%3Aunresolved+stream_url&referrer=issue-stream&sort=new&statsPeriod=90d
  • Loading branch information
kennethjiang committed Jun 26, 2024
1 parent 46cbe50 commit c616760
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion moonraker_obico/server_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def post_pic_to_server(self, webcam_config, viewing_boost=False):
)
resp = self.send_http_request('POST', '/api/v1/octo/pic/', timeout=60, files=files, data=data, raise_exception=True, skip_debug_logging=True)
_logger.debug('Jpeg posted to server - camera name: {} - viewing_boost: {} - {}'.format(webcam_config.name, viewing_boost, resp))
except (URLError, HTTPError, requests.exceptions.RequestException) as e:
except (URLError, HTTPError, requests.exceptions.RequestException, ValueError) as e:
_logger.warn('Failed to capture jpeg - ' + str(e))
return

Expand Down
8 changes: 4 additions & 4 deletions moonraker_obico/webcam_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def capture_jpeg(webcam_config, force_stream_url=False):
else:
stream_url = webcam_config.stream_url
if not stream_url:
raise Exception('Invalid snapshot URL or stream URL in webcam setting: "{}"'.format(webcam_config))
raise ValueError('Invalid snapshot URL or stream URL in webcam setting: "{}"'.format(webcam_config))

with closing(urlopen(stream_url)) as res:
chunker = MjpegStreamChunker()
Expand All @@ -56,9 +56,9 @@ def capture_jpeg(webcam_config, force_stream_url=False):
data = res.readline()
data_bytes += len(data)
if data == b'':
raise Exception('End of stream before a valid jpeg is found')
raise ValueError('End of stream before a valid jpeg is found')
if data_bytes > MAX_JPEG_SIZE:
raise Exception('Reached the size cap before a valid jpeg is found.')
raise ValueError('Reached the size cap before a valid jpeg is found.')

mjpg = chunker.findMjpegChunk(data)
if mjpg:
Expand All @@ -68,7 +68,7 @@ def capture_jpeg(webcam_config, force_stream_url=False):
if mjpeg_headers_index > 0:
return mjpg[mjpeg_headers_index+4:]
else:
raise Exception('Wrong mjpeg data format')
raise ValueError('Wrong mjpeg data format')


class MjpegStreamChunker:
Expand Down

0 comments on commit c616760

Please sign in to comment.