Skip to content

Commit

Permalink
Fix crash, if Artemis is closed while the lib is connected
Browse files Browse the repository at this point in the history
  • Loading branch information
Nama committed Apr 7, 2021
1 parent 5f825ab commit 88bf77d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions artemisremotecontrol/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from requests import get, post
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError, ChunkedEncodingError
import logging
from os import environ
from json import loads, dumps
Expand All @@ -13,7 +13,7 @@ def _getapiurl(ep):

try:
response = get(url_endpoints)
except ConnectionError:
except (ConnectionError, ChunkedEncodingError):
logging.error('Can\'t connect to Artemis')
return None
if response.status_code != 200:
Expand Down Expand Up @@ -51,7 +51,7 @@ def setleds(deviceids: list, ledids: list, color: str):
logging.debug(data)
try:
response = post(url, data=str(data))
except ConnectionError:
except (ConnectionError, ChunkedEncodingError):
logging.error('Can\'t connect to Artemis to set color')
return
if response.status_code != 200:
Expand Down
4 changes: 2 additions & 2 deletions scripts/tasmota.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from time import sleep
from threading import Thread
from requests import get
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError, ChunkedEncodingError
from artemisremotecontrol.config import Config
from artemisremotecontrol import getleds, setleds

Expand All @@ -26,7 +26,7 @@ def loop():
try:
response = get(url, timeout=1)
status = response.status_code
except ConnectionError:
except (ConnectionError, ChunkedEncodingError):
status = False
if status != 200:
# send "Disconnected" state
Expand Down

0 comments on commit 88bf77d

Please sign in to comment.