Skip to content

Commit

Permalink
art.py: handle errors gracefully
Browse files Browse the repository at this point in the history
required for 2019 samsung models
  • Loading branch information
thypon committed May 2, 2023
1 parent ae5d2b3 commit fbcc9fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions samsungtvws/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _send_art_request(
assert self.connection
event: Optional[str] = None
sub_event: Optional[str] = None
while event != wait_for_event:
while event != wait_for_event and event != 'error':
data = self.connection.recv()
response = helper.process_api_response(data)
event = response.get("event", "*")
Expand All @@ -121,7 +121,7 @@ def _send_art_request(
# Check sub event, reset event if it doesn't match
data = json.loads(response["data"])
sub_event = data.get("event", "*")
if sub_event != wait_for_sub_event:
if sub_event != wait_for_sub_event and sub_event != 'error':
event = None

return response
Expand Down Expand Up @@ -234,6 +234,9 @@ def upload(self, file, matte="shadowbox_polar", file_type="png", date=None):
)
assert response
data = json.loads(response["data"])
if data['event'] == 'error':
raise RuntimeError("Upload failed with error number %s" % data["error_code"])

conn_info = json.loads(data["conn_info"])

header = json.dumps(
Expand Down

0 comments on commit fbcc9fc

Please sign in to comment.