Update docstrings (#7361)
* Update docstrings * Update docstrings * Update docstrings * Update docstrings * update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update tomato.py * Update isy994.py * Lint + fix tests * Lint
This commit is contained in:
1 parent
e22e70a01a
commit
3ee4d1060f
264 files changed
+1686
-1768
No files matched your search
@@ -21,14 +21,19 @@ from homeassistant.const import (
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
# Return cached results if last scan was less then this time ago.
|
||||
REQUIREMENTS = ['pexpect==4.0.1']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_MODE = 'mode'
|
||||
CONF_PROTOCOL = 'protocol'
|
||||
CONF_PUB_KEY = 'pub_key'
|
||||
CONF_SSH_KEY = 'ssh_key'
|
||||
|
||||
DEFAULT_SSH_PORT = 22
|
||||
|
||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)
|
||||
|
||||
CONF_PROTOCOL = 'protocol'
|
||||
CONF_MODE = 'mode'
|
||||
DEFAULT_SSH_PORT = 22
|
||||
CONF_SSH_KEY = 'ssh_key'
|
||||
CONF_PUB_KEY = 'pub_key'
|
||||
SECRET_GROUP = 'Password or SSH Key'
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
@@ -47,9 +52,6 @@ PLATFORM_SCHEMA = vol.All(
|
||||
}))
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
REQUIREMENTS = ['pexpect==4.0.1']
|
||||
|
||||
_LEASES_CMD = 'cat /var/lib/misc/dnsmasq.leases'
|
||||
_LEASES_REGEX = re.compile(
|
||||
r'\w+\s' +
|
||||
@@ -57,7 +59,7 @@ _LEASES_REGEX = re.compile(
|
||||
r'(?P<ip>([0-9]{1,3}[\.]){3}[0-9]{1,3})\s' +
|
||||
r'(?P<host>([^\s]+))')
|
||||
|
||||
# command to get both 5GHz and 2.4GHz clients
|
||||
# Command to get both 5GHz and 2.4GHz clients
|
||||
_WL_CMD = '{ wl -i eth2 assoclist & wl -i eth1 assoclist ; }'
|
||||
_WL_REGEX = re.compile(
|
||||
r'\w+\s' +
|
||||
@@ -126,12 +128,12 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
elif self.password:
|
||||
self.ssh_args['password'] = self.password
|
||||
else:
|
||||
_LOGGER.error('No password or private key specified')
|
||||
_LOGGER.error("No password or private key specified")
|
||||
self.success_init = False
|
||||
return
|
||||
else:
|
||||
if not self.password:
|
||||
_LOGGER.error('No password specified')
|
||||
_LOGGER.error("No password specified")
|
||||
self.success_init = False
|
||||
return
|
||||
|
||||
@@ -188,10 +190,10 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
try:
|
||||
ssh.login(self.host, self.username, **self.ssh_args)
|
||||
except exceptions.EOF as err:
|
||||
_LOGGER.error('Connection refused. Is SSH enabled?')
|
||||
_LOGGER.error("Connection refused. SSH enabled?")
|
||||
return None
|
||||
except pxssh.ExceptionPxssh as err:
|
||||
_LOGGER.error('Unable to connect via SSH: %s', str(err))
|
||||
_LOGGER.error("Unable to connect via SSH: %s", str(err))
|
||||
return None
|
||||
|
||||
try:
|
||||
@@ -218,7 +220,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
return AsusWrtResult(neighbors, leases_result, arp_result,
|
||||
nvram_result)
|
||||
except pxssh.ExceptionPxssh as exc:
|
||||
_LOGGER.error('Unexpected response from router: %s', exc)
|
||||
_LOGGER.error("Unexpected response from router: %s", exc)
|
||||
return None
|
||||
|
||||
def telnet_connection(self):
|
||||
@@ -252,16 +254,16 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
return AsusWrtResult(neighbors, leases_result, arp_result,
|
||||
nvram_result)
|
||||
except EOFError:
|
||||
_LOGGER.error('Unexpected response from router')
|
||||
_LOGGER.error("Unexpected response from router")
|
||||
return None
|
||||
except ConnectionRefusedError:
|
||||
_LOGGER.error('Connection refused by router, is telnet enabled?')
|
||||
_LOGGER.error("Connection refused by router. Telnet enabled?")
|
||||
return None
|
||||
except socket.gaierror as exc:
|
||||
_LOGGER.error('Socket exception: %s', exc)
|
||||
_LOGGER.error("Socket exception: %s", exc)
|
||||
return None
|
||||
except OSError as exc:
|
||||
_LOGGER.error('OSError: %s', exc)
|
||||
_LOGGER.error("OSError: %s", exc)
|
||||
return None
|
||||
|
||||
def get_asuswrt_data(self):
|
||||
@@ -289,7 +291,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
match = _WL_REGEX.search(lease.decode('utf-8'))
|
||||
|
||||
if not match:
|
||||
_LOGGER.warning('Could not parse wl row: %s', lease)
|
||||
_LOGGER.warning("Could not parse wl row: %s", lease)
|
||||
continue
|
||||
|
||||
host = ''
|
||||
@@ -301,7 +303,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
arp_match = _ARP_REGEX.search(
|
||||
arp.decode('utf-8').lower())
|
||||
if not arp_match:
|
||||
_LOGGER.warning('Could not parse arp row: %s', arp)
|
||||
_LOGGER.warning("Could not parse arp row: %s", arp)
|
||||
continue
|
||||
|
||||
devices[arp_match.group('ip')] = {
|
||||
@@ -316,7 +318,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
if match.group('mac').upper() in nvr.decode('utf-8'):
|
||||
nvram_match = _NVRAM_REGEX.search(nvr.decode('utf-8'))
|
||||
if not nvram_match:
|
||||
_LOGGER.warning('Could not parse nvr row: %s', nvr)
|
||||
_LOGGER.warning("Could not parse nvr row: %s", nvr)
|
||||
continue
|
||||
|
||||
# skip current check if already in ARP table
|
||||
@@ -337,7 +339,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
match = _LEASES_REGEX.search(lease.decode('utf-8'))
|
||||
|
||||
if not match:
|
||||
_LOGGER.warning('Could not parse lease row: %s', lease)
|
||||
_LOGGER.warning("Could not parse lease row: %s", lease)
|
||||
continue
|
||||
|
||||
# For leases where the client doesn't set a hostname, ensure it
|
||||
@@ -356,7 +358,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
||||
for neighbor in result.neighbors:
|
||||
match = _IP_NEIGH_REGEX.search(neighbor.decode('utf-8'))
|
||||
if not match:
|
||||
_LOGGER.warning('Could not parse neighbor row: %s', neighbor)
|
||||
_LOGGER.warning("Could not parse neighbor row: %s", neighbor)
|
||||
continue
|
||||
if match.group('ip') in devices:
|
||||
devices[match.group('ip')]['status'] = match.group('status')
|
||||
|
||||
Reference in new issue
Block a user