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
@@ -12,11 +12,11 @@ import time
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_PORT, CONF_PREFIX, EVENT_HOMEASSISTANT_START,
|
||||
EVENT_HOMEASSISTANT_STOP, EVENT_STATE_CHANGED)
|
||||
from homeassistant.helpers import state
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -35,7 +35,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the Graphite feeder."""
|
||||
"""Set up the Graphite feeder."""
|
||||
conf = config[DOMAIN]
|
||||
host = conf.get(CONF_HOST)
|
||||
prefix = conf.get(CONF_PREFIX)
|
||||
@@ -75,28 +75,28 @@ class GraphiteFeeder(threading.Thread):
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP,
|
||||
self.shutdown)
|
||||
hass.bus.listen(EVENT_STATE_CHANGED, self.event_listener)
|
||||
_LOGGER.debug('Graphite feeding to %s:%i initialized',
|
||||
_LOGGER.debug("Graphite feeding to %s:%i initialized",
|
||||
self._host, self._port)
|
||||
|
||||
def start_listen(self, event):
|
||||
"""Start event-processing thread."""
|
||||
_LOGGER.debug('Event processing thread started')
|
||||
_LOGGER.debug("Event processing thread started")
|
||||
self._we_started = True
|
||||
self.start()
|
||||
|
||||
def shutdown(self, event):
|
||||
"""Signal shutdown of processing event."""
|
||||
_LOGGER.debug('Event processing signaled exit')
|
||||
_LOGGER.debug("Event processing signaled exit")
|
||||
self._queue.put(self._quit_object)
|
||||
|
||||
def event_listener(self, event):
|
||||
"""Queue an event for processing."""
|
||||
if self.is_alive() or not self._we_started:
|
||||
_LOGGER.debug('Received event')
|
||||
_LOGGER.debug("Received event")
|
||||
self._queue.put(event)
|
||||
else:
|
||||
_LOGGER.error('Graphite feeder thread has died, not '
|
||||
'queuing event!')
|
||||
_LOGGER.error(
|
||||
"Graphite feeder thread has died, not queuing event!")
|
||||
|
||||
def _send_to_graphite(self, data):
|
||||
"""Send data to Graphite."""
|
||||
@@ -122,25 +122,25 @@ class GraphiteFeeder(threading.Thread):
|
||||
if isinstance(value, (float, int))]
|
||||
if not lines:
|
||||
return
|
||||
_LOGGER.debug('Sending to graphite: %s', lines)
|
||||
_LOGGER.debug("Sending to graphite: %s", lines)
|
||||
try:
|
||||
self._send_to_graphite('\n'.join(lines))
|
||||
except socket.gaierror:
|
||||
_LOGGER.error('Unable to connect to host %s', self._host)
|
||||
_LOGGER.error("Unable to connect to host %s", self._host)
|
||||
except socket.error:
|
||||
_LOGGER.exception('Failed to send data to graphite')
|
||||
_LOGGER.exception("Failed to send data to graphite")
|
||||
|
||||
def run(self):
|
||||
"""Run the process to export the data."""
|
||||
while True:
|
||||
event = self._queue.get()
|
||||
if event == self._quit_object:
|
||||
_LOGGER.debug('Event processing thread stopped')
|
||||
_LOGGER.debug("Event processing thread stopped")
|
||||
self._queue.task_done()
|
||||
return
|
||||
elif (event.event_type == EVENT_STATE_CHANGED and
|
||||
event.data.get('new_state')):
|
||||
_LOGGER.debug('Processing STATE_CHANGED event for %s',
|
||||
_LOGGER.debug("Processing STATE_CHANGED event for %s",
|
||||
event.data['entity_id'])
|
||||
try:
|
||||
self._report_attributes(event.data['entity_id'],
|
||||
@@ -149,9 +149,9 @@ class GraphiteFeeder(threading.Thread):
|
||||
except Exception:
|
||||
# Catch this so we can avoid the thread dying and
|
||||
# make it visible.
|
||||
_LOGGER.exception('Failed to process STATE_CHANGED event')
|
||||
_LOGGER.exception("Failed to process STATE_CHANGED event")
|
||||
else:
|
||||
_LOGGER.warning('Processing unexpected event type %s',
|
||||
_LOGGER.warning("Processing unexpected event type %s",
|
||||
event.event_type)
|
||||
|
||||
self._queue.task_done()
|
||||
Reference in new issue
Block a user