parent
1e352d37d0
commit
0863d50210
|
@ -74,7 +74,7 @@ def monkey_patch_asyncio():
|
|||
|
||||
|
||||
def validate_python() -> None:
|
||||
"""Validate we're running the right Python version."""
|
||||
"""Validate that the right Python version is running."""
|
||||
if sys.platform == "win32" and \
|
||||
sys.version_info[:3] < REQUIRED_PYTHON_VER_WIN:
|
||||
print("Home Assistant requires at least Python {}.{}.{}".format(
|
||||
|
@ -215,7 +215,7 @@ def daemonize() -> None:
|
|||
|
||||
|
||||
def check_pid(pid_file: str) -> None:
|
||||
"""Check that HA is not already running."""
|
||||
"""Check that Home Assistant is not already running."""
|
||||
# Check pid file
|
||||
try:
|
||||
pid = int(open(pid_file, 'r').readline())
|
||||
|
@ -329,7 +329,7 @@ def setup_and_run_hass(config_dir: str,
|
|||
|
||||
|
||||
def try_to_restart() -> None:
|
||||
"""Attempt to clean up state and start a new homeassistant instance."""
|
||||
"""Attempt to clean up state and start a new Home Assistant instance."""
|
||||
# Things should be mostly shut down already at this point, now just try
|
||||
# to clean up things that may have been left behind.
|
||||
sys.stderr.write('Home Assistant attempting to restart.\n')
|
||||
|
@ -361,11 +361,11 @@ def try_to_restart() -> None:
|
|||
else:
|
||||
os.closerange(3, max_fd)
|
||||
|
||||
# Now launch into a new instance of Home-Assistant. If this fails we
|
||||
# Now launch into a new instance of Home Assistant. If this fails we
|
||||
# fall through and exit with error 100 (RESTART_EXIT_CODE) in which case
|
||||
# systemd will restart us when RestartForceExitStatus=100 is set in the
|
||||
# systemd.service file.
|
||||
sys.stderr.write("Restarting Home-Assistant\n")
|
||||
sys.stderr.write("Restarting Home Assistant\n")
|
||||
args = cmdline()
|
||||
os.execv(args[0], args)
|
||||
|
||||
|
|
|
@ -218,8 +218,7 @@ def async_setup(hass, config: dict):
|
|||
if not fan.should_poll:
|
||||
continue
|
||||
|
||||
update_coro = hass.async_add_job(
|
||||
fan.async_update_ha_state(True))
|
||||
update_coro = hass.async_add_job(fan.async_update_ha_state(True))
|
||||
if hasattr(fan, 'async_update'):
|
||||
update_tasks.append(update_coro)
|
||||
else:
|
||||
|
|
|
@ -36,7 +36,7 @@ SPEED_TO_VALUE = {
|
|||
|
||||
|
||||
def get_device(values, **kwargs):
|
||||
"""Create zwave entity device."""
|
||||
"""Create Z-Wave entity device."""
|
||||
return ZwaveFan(values)
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ CONF_TRUSTED_NETWORKS = 'trusted_networks'
|
|||
CONF_LOGIN_ATTEMPTS_THRESHOLD = 'login_attempts_threshold'
|
||||
CONF_IP_BAN_ENABLED = 'ip_ban_enabled'
|
||||
|
||||
# TLS configuation follows the best-practice guidelines specified here:
|
||||
# TLS configuration follows the best-practice guidelines specified here:
|
||||
# https://wiki.mozilla.org/Security/Server_Side_TLS
|
||||
# Intermediate guidelines are followed.
|
||||
SSL_VERSION = ssl.PROTOCOL_SSLv23
|
||||
|
@ -339,7 +339,7 @@ class HomeAssistantWSGI(object):
|
|||
|
||||
@asyncio.coroutine
|
||||
def stop(self):
|
||||
"""Stop the wsgi server."""
|
||||
"""Stop the WSGI server."""
|
||||
if self.server:
|
||||
self.server.close()
|
||||
yield from self.server.wait_closed()
|
||||
|
|
|
@ -19,6 +19,8 @@ from .const import (
|
|||
KEY_FAILED_LOGIN_ATTEMPTS)
|
||||
from .util import get_real_ip
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
NOTIFICATION_ID_BAN = 'ip-ban'
|
||||
NOTIFICATION_ID_LOGIN = 'http-login'
|
||||
|
||||
|
@ -29,8 +31,6 @@ SCHEMA_IP_BAN_ENTRY = vol.Schema({
|
|||
vol.Optional('banned_at'): vol.Any(None, cv.datetime)
|
||||
})
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def ban_middleware(app, handler):
|
||||
|
|
|
@ -6,7 +6,7 @@ KEY_REAL_IP = 'ha_real_ip'
|
|||
KEY_BANS_ENABLED = 'ha_bans_enabled'
|
||||
KEY_BANNED_IPS = 'ha_banned_ips'
|
||||
KEY_FAILED_LOGIN_ATTEMPTS = 'ha_failed_login_attempts'
|
||||
KEY_LOGIN_THRESHOLD = 'ha_login_treshold'
|
||||
KEY_LOGIN_THRESHOLD = 'ha_login_threshold'
|
||||
KEY_DEVELOPMENT = 'ha_development'
|
||||
|
||||
HTTP_HEADER_X_FORWARDED_FOR = 'X-Forwarded-For'
|
||||
|
|
|
@ -102,7 +102,7 @@ def valid_discovery_topic(value):
|
|||
_VALID_QOS_SCHEMA = vol.All(vol.Coerce(int), vol.In([0, 1, 2]))
|
||||
|
||||
CLIENT_KEY_AUTH_MSG = 'client_key and client_cert must both be present in ' \
|
||||
'the mqtt broker config'
|
||||
'the MQTT broker configuration'
|
||||
|
||||
MQTT_WILL_BIRTH_SCHEMA = vol.Schema({
|
||||
vol.Required(ATTR_TOPIC): valid_publish_topic,
|
||||
|
@ -126,9 +126,8 @@ CONFIG_SCHEMA = vol.Schema({
|
|||
vol.Inclusive(CONF_CLIENT_CERT, 'client_key_auth',
|
||||
msg=CLIENT_KEY_AUTH_MSG): cv.isfile,
|
||||
vol.Optional(CONF_TLS_INSECURE): cv.boolean,
|
||||
vol.Optional(CONF_TLS_VERSION,
|
||||
default=DEFAULT_TLS_PROTOCOL): vol.Any('auto', '1.0',
|
||||
'1.1', '1.2'),
|
||||
vol.Optional(CONF_TLS_VERSION, default=DEFAULT_TLS_PROTOCOL):
|
||||
vol.Any('auto', '1.0', '1.1', '1.2'),
|
||||
vol.Optional(CONF_PROTOCOL, default=DEFAULT_PROTOCOL):
|
||||
vol.All(cv.string, vol.In([PROTOCOL_31, PROTOCOL_311])),
|
||||
vol.Optional(CONF_EMBEDDED): HBMQTT_CONFIG_SCHEMA,
|
||||
|
@ -237,9 +236,7 @@ def subscribe(hass, topic, msg_callback, qos=DEFAULT_QOS,
|
|||
encoding='utf-8'):
|
||||
"""Subscribe to an MQTT topic."""
|
||||
async_remove = run_coroutine_threadsafe(
|
||||
async_subscribe(hass, topic, msg_callback,
|
||||
qos, encoding),
|
||||
hass.loop
|
||||
async_subscribe(hass, topic, msg_callback, qos, encoding), hass.loop
|
||||
).result()
|
||||
|
||||
def remove():
|
||||
|
|
|
@ -125,7 +125,7 @@ def async_aiohttp_proxy_stream(hass, request, stream, content_type,
|
|||
@callback
|
||||
# pylint: disable=invalid-name
|
||||
def _async_register_clientsession_shutdown(hass, clientsession):
|
||||
"""Register ClientSession close on homeassistant shutdown.
|
||||
"""Register ClientSession close on Home Assistant shutdown.
|
||||
|
||||
This method must be run in the event loop.
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Helper methods to help with platform discovery.
|
||||
|
||||
There are two different types of discoveries that can be fired/listened for.
|
||||
- listen/discover is for services. These are targetted at a component.
|
||||
- listen/discover is for services. These are targeted at a component.
|
||||
- listen_platform/discover_platform is for platforms. These are used by
|
||||
components to allow discovery of their platforms.
|
||||
"""
|
||||
|
|
|
@ -10,7 +10,7 @@ DATA_DISPATCHER = 'dispatcher'
|
|||
|
||||
|
||||
def dispatcher_connect(hass, signal, target):
|
||||
"""Connect a callable function to a singal."""
|
||||
"""Connect a callable function to a signal."""
|
||||
async_unsub = run_callback_threadsafe(
|
||||
hass.loop, async_dispatcher_connect, hass, signal, target).result()
|
||||
|
||||
|
@ -23,7 +23,7 @@ def dispatcher_connect(hass, signal, target):
|
|||
|
||||
@callback
|
||||
def async_dispatcher_connect(hass, signal, target):
|
||||
"""Connect a callable function to a singal.
|
||||
"""Connect a callable function to a signal.
|
||||
|
||||
This method must be run in the event loop.
|
||||
"""
|
||||
|
|
|
@ -9,7 +9,7 @@ DATA_LOCATION_CACHE = 'astral_location_cache'
|
|||
|
||||
@callback
|
||||
def get_astral_location(hass):
|
||||
"""Get an astral location for the current hass configuration."""
|
||||
"""Get an astral location for the current Home Assistant configuration."""
|
||||
from astral import Location
|
||||
|
||||
latitude = hass.config.latitude
|
||||
|
|
|
@ -11,6 +11,7 @@ from typing import Optional
|
|||
import pkg_resources
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
INSTALL_LOCK = threading.Lock()
|
||||
|
||||
|
||||
|
@ -26,7 +27,7 @@ def install_package(package: str, upgrade: bool=True,
|
|||
if check_package_exists(package, target):
|
||||
return True
|
||||
|
||||
_LOGGER.info('Attempting install of %s', package)
|
||||
_LOGGER.info("Attempting install of %s", package)
|
||||
args = [sys.executable, '-m', 'pip', 'install', '--quiet', package]
|
||||
if upgrade:
|
||||
args.append('--upgrade')
|
||||
|
@ -39,7 +40,7 @@ def install_package(package: str, upgrade: bool=True,
|
|||
process = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||
_, stderr = process.communicate()
|
||||
if process.returncode != 0:
|
||||
_LOGGER.error('Unable to install package %s: %s',
|
||||
_LOGGER.error("Unable to install package %s: %s",
|
||||
package, stderr.decode('utf-8').lstrip().strip())
|
||||
return False
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
import logging
|
||||
from numbers import Number
|
||||
|
||||
from homeassistant.const import (
|
||||
TEMP_CELSIUS, TEMP_FAHRENHEIT, LENGTH_CENTIMETERS, LENGTH_METERS,
|
||||
LENGTH_KILOMETERS, LENGTH_INCHES, LENGTH_FEET, LENGTH_YARD, LENGTH_MILES,
|
||||
VOLUME_LITERS, VOLUME_MILLILITERS, VOLUME_GALLONS, VOLUME_FLUID_OUNCE,
|
||||
MASS_GRAMS, MASS_KILOGRAMS, MASS_OUNCES, MASS_POUNDS,
|
||||
CONF_UNIT_SYSTEM_METRIC,
|
||||
CONF_UNIT_SYSTEM_IMPERIAL, LENGTH, MASS, VOLUME, TEMPERATURE,
|
||||
UNIT_NOT_RECOGNIZED_TEMPLATE)
|
||||
CONF_UNIT_SYSTEM_METRIC, CONF_UNIT_SYSTEM_IMPERIAL, LENGTH, MASS, VOLUME,
|
||||
TEMPERATURE, UNIT_NOT_RECOGNIZED_TEMPLATE)
|
||||
from homeassistant.util import temperature as temperature_util
|
||||
from homeassistant.util import distance as distance_util
|
||||
|
||||
|
|
Loading…
Reference in New Issue