Add support for Python 3.12 (#101651)
This commit is contained in:
parent
535e2b81ce
commit
ba91aaa28d
28 changed files with 296 additions and 93 deletions
|
@ -3,9 +3,8 @@ from __future__ import annotations
|
|||
|
||||
import binascii
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from pysnmp.entity import config as cfg
|
||||
from pysnmp.entity.rfc3413.oneliner import cmdgen
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.device_tracker import (
|
||||
|
@ -15,6 +14,7 @@ from homeassistant.components.device_tracker import (
|
|||
)
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
|
@ -26,6 +26,11 @@ from .const import (
|
|||
DEFAULT_COMMUNITY,
|
||||
)
|
||||
|
||||
if sys.version_info < (3, 12):
|
||||
from pysnmp.entity import config as cfg
|
||||
from pysnmp.entity.rfc3413.oneliner import cmdgen
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
|
||||
|
@ -41,6 +46,10 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
|
|||
|
||||
def get_scanner(hass: HomeAssistant, config: ConfigType) -> SnmpScanner | None:
|
||||
"""Validate the configuration and return an SNMP scanner."""
|
||||
if sys.version_info >= (3, 12):
|
||||
raise HomeAssistantError(
|
||||
"SNMP is not supported on Python 3.12. Please use Python 3.11."
|
||||
)
|
||||
scanner = SnmpScanner(config[DOMAIN])
|
||||
|
||||
return scanner if scanner.success_init else None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue