chore: adopt the NAPALM driver standard #6
No files matched your search
@@ -4,7 +4,6 @@ import socket
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from napalm.base.exceptions import ConnectionException
|
from napalm.base.exceptions import ConnectionException
|
||||||
|
|
||||||
from napalm_device_types import FingerprintRule, MediaDriver, PortSpec
|
from napalm_device_types import FingerprintRule, MediaDriver, PortSpec
|
||||||
|
|
||||||
"""NAPALM driver for Sonos speakers.
|
"""NAPALM driver for Sonos speakers.
|
||||||
@@ -15,7 +14,6 @@ media-playback controls.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SonosDriver(MediaDriver):
|
class SonosDriver(MediaDriver):
|
||||||
"""NAPALM driver for controlling Sonos speakers.
|
"""NAPALM driver for controlling Sonos speakers.
|
||||||
|
|
||||||
@@ -74,9 +72,7 @@ class SonosDriver(MediaDriver):
|
|||||||
if self._device is None:
|
if self._device is None:
|
||||||
return {"is_alive": False}
|
return {"is_alive": False}
|
||||||
try:
|
try:
|
||||||
sock = socket.create_connection(
|
sock = socket.create_connection((self.hostname, 1400), timeout=5)
|
||||||
(self.hostname, 1400), timeout=5
|
|
||||||
)
|
|
||||||
sock.close()
|
sock.close()
|
||||||
return {"is_alive": True}
|
return {"is_alive": True}
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|||||||
+8
-1
@@ -48,7 +48,14 @@ include = ["napalm_sonos*"]
|
|||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 100
|
line-length = 100
|
||||||
target-version = "py39"
|
target-version = "py310"
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = ["E", "F", "I", "UP", "B"]
|
||||||
|
|
||||||
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
# Recorded device output keeps its lines.
|
||||||
|
"tests/**" = ["E501"]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
testpaths = ["tests"]
|
testpaths = ["tests"]
|
||||||
Reference in new issue
Block a user