Demote start control to warning

This commit is contained in:
Blallo 2021-09-17 10:26:29 +02:00
parent 8f5dcccf70
commit c3f6423771
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F

View file

@ -19,13 +19,19 @@ def is_writable(d):
return os.access(d, os.W_OK) return os.access(d, os.W_OK)
def check_remote_store(url: str) -> None:
try:
with urllib.request.urlopen(url) as req:
if req.code not in OK_CODES:
logger.warn(f"Audio input {url} not responding")
except Exception as e:
logger.warn(f"Audio input {url} not accessible: {e}")
def pre_check_permissions(): def pre_check_permissions():
audio_input = get_config()["AUDIO_INPUT"] audio_input = get_config()["AUDIO_INPUT"]
if audio_input.startswith("http://") or audio_input.startswith("https://"): if audio_input.startswith("http://") or audio_input.startswith("https://"):
with urllib.request.urlopen(audio_input) as req: check_remote_store(audio_input)
if req.code not in OK_CODES:
yield f"Audio input {audio_input} not accessible"
sys.exit(10)
else: else:
if is_writable(audio_input): if is_writable(audio_input):
yield "Audio input '%s' writable" % audio_input yield "Audio input '%s' writable" % audio_input