From 91bebca0b6664b26b8385331384b4b38b9404444 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 5 Feb 2017 11:22:32 +0100 Subject: [PATCH] Upgrade pysnmp to 4.3.3 (#5757) --- .../components/device_tracker/snmp.py | 26 +++++++++---------- homeassistant/components/sensor/snmp.py | 8 +++--- requirements_all.txt | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/device_tracker/snmp.py b/homeassistant/components/device_tracker/snmp.py index 43c0662e568..4cbaa557517 100644 --- a/homeassistant/components/device_tracker/snmp.py +++ b/homeassistant/components/device_tracker/snmp.py @@ -17,24 +17,24 @@ from homeassistant.components.device_tracker import ( from homeassistant.const import CONF_HOST from homeassistant.util import Throttle -# Return cached results if last scan was less then this time ago. -MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) - _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['pysnmp==4.3.2'] -CONF_COMMUNITY = "community" -CONF_AUTHKEY = "authkey" -CONF_PRIVKEY = "privkey" -CONF_BASEOID = "baseoid" +REQUIREMENTS = ['pysnmp==4.3.3'] -DEFAULT_COMMUNITY = "public" +CONF_COMMUNITY = 'community' +CONF_AUTHKEY = 'authkey' +CONF_PRIVKEY = 'privkey' +CONF_BASEOID = 'baseoid' + +DEFAULT_COMMUNITY = 'public' + +MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_COMMUNITY, default=DEFAULT_COMMUNITY): cv.string, - vol.Inclusive(CONF_AUTHKEY, "keys"): cv.string, - vol.Inclusive(CONF_PRIVKEY, "keys"): cv.string, + vol.Inclusive(CONF_AUTHKEY, 'keys'): cv.string, + vol.Inclusive(CONF_PRIVKEY, 'keys'): cv.string, vol.Required(CONF_BASEOID): cv.string }) @@ -119,14 +119,14 @@ class SnmpScanner(DeviceScanner): return # pylint: disable=no-member if errstatus: - _LOGGER.error('SNMP error: %s at %s', errstatus.prettyPrint(), + _LOGGER.error("SNMP error: %s at %s", errstatus.prettyPrint(), errindex and restable[int(errindex) - 1][0] or '?') return for resrow in restable: for _, val in resrow: mac = binascii.hexlify(val.asOctets()).decode('utf-8') - _LOGGER.debug('Found mac %s', mac) + _LOGGER.debug("Found MAC %s", mac) mac = ':'.join([mac[i:i+2] for i in range(0, len(mac), 2)]) devices.append({'mac': mac}) return devices diff --git a/homeassistant/components/sensor/snmp.py b/homeassistant/components/sensor/snmp.py index b5e3b16b5d1..6a991f28898 100644 --- a/homeassistant/components/sensor/snmp.py +++ b/homeassistant/components/sensor/snmp.py @@ -16,7 +16,7 @@ from homeassistant.const import ( import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle -REQUIREMENTS = ['pysnmp==4.3.2'] +REQUIREMENTS = ['pysnmp==4.3.3'] _LOGGER = logging.getLogger(__name__) @@ -41,7 +41,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup the SNMP sensor.""" + """Set up the SNMP sensor.""" from pysnmp.hlapi import (getCmd, CommunityData, SnmpEngine, UdpTransportTarget, ContextData, ObjectType, ObjectIdentity) @@ -61,7 +61,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): ObjectType(ObjectIdentity(baseoid)))) if errindication: - _LOGGER.error('Please check the details in the configuration file') + _LOGGER.error("Please check the details in the configuration file") return False else: data = SnmpData(host, port, community, baseoid) @@ -128,7 +128,7 @@ class SnmpData(object): if errindication: _LOGGER.error("SNMP error: %s", errindication) elif errstatus: - _LOGGER.error('SNMP error: %s at %s', errstatus.prettyPrint(), + _LOGGER.error("SNMP error: %s at %s", errstatus.prettyPrint(), errindex and restable[-1][int(errindex) - 1] or '?') else: for resrow in restable: diff --git a/requirements_all.txt b/requirements_all.txt index b21a78803c8..9dcf8198d2d 100755 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -505,7 +505,7 @@ pysma==0.1.3 # homeassistant.components.device_tracker.snmp # homeassistant.components.sensor.snmp -pysnmp==4.3.2 +pysnmp==4.3.3 # homeassistant.components.digital_ocean python-digitalocean==1.10.1