10000 Use voluptuous for supervisord by fabaff · Pull Request #3069 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use voluptuous for supervisord #3069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
21 changes: 17 additions & 4 deletions homeassistant/components/sensor/supervisord.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,41 @@
import logging
import xmlrpc.client

import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_URL
from homeassistant.helpers.entity import Entity
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

DEFAULT_URL = 'http://localhost:9001/RPC2'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_URL, default=DEFAULT_URL): cv.url,
})


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Supervisord platform."""
url = config.get(CONF_URL)
try:
supervisor_server = xmlrpc.client.ServerProxy(
config.get('url', 'http://localhost:9001/RPC2'))
supervisor_server = xmlrpc.client.ServerProxy(url)
except ConnectionRefusedError:
_LOGGER.error('Could not connect to Supervisord')
return
return False

processes = supervisor_server.supervisor.getAllProcessInfo()

add_devices(
[SupervisorProcessSensor(info, supervisor_server)
for info in processes])


class SupervisorProcessSensor(Entity):
"""Represent a supervisor-monitored process."""
"""Representation of a supervisor-monitored process."""

# pylint: disable=abstract-method
def __init__(self, info, server):
Expand Down
0