mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 04:06:33 +00:00
Handle both cases of bind failures (#2099)
This commit is contained in:
parent
38db375fea
commit
9dc2f43ffb
@ -6,7 +6,9 @@ import sentry_sdk
|
|||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
RE_BIND_FAILED = re.compile(r".*Bind for.*:(\d*) failed: port is already allocated.*")
|
RE_BIND_FAILED = re.compile(
|
||||||
|
r".*[listen tcp|Bind for].*(?:[0-9]{1,3}\.){3}[0-9]{1,3}:(\d*).*[bind|failed]:[address already in use|port is already allocated].*"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def format_message(message: str) -> str:
|
def format_message(message: str) -> str:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from supervisor.utils.log_format import format_message
|
from supervisor.utils.log_format import format_message
|
||||||
|
|
||||||
|
|
||||||
def test_format_message():
|
def test_format_message_port():
|
||||||
"""Tests for message formater."""
|
"""Tests for message formater."""
|
||||||
message = '500 Server Error: Internal Server Error: Bind for 0.0.0.0:80 failed: port is already allocated")'
|
message = '500 Server Error: Internal Server Error: Bind for 0.0.0.0:80 failed: port is already allocated")'
|
||||||
assert (
|
assert (
|
||||||
@ -11,6 +11,15 @@ def test_format_message():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_format_message_port_alternative():
|
||||||
|
"""Tests for message formater."""
|
||||||
|
message = 'Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use")'
|
||||||
|
assert (
|
||||||
|
format_message(message)
|
||||||
|
== "Port '80' is already in use by something else on the host."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_exeption():
|
def test_exeption():
|
||||||
"""Tests the exception handling."""
|
"""Tests the exception handling."""
|
||||||
message = b"byte"
|
message = b"byte"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user