From 0863d502102c0f66511097f6f237e4f3de7b1f4c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 8 Jun 2017 15:53:12 +0200 Subject: [PATCH] Fix typos (#7957) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an optional extended description… --- homeassistant/__main__.py | 10 +++++----- homeassistant/components/fan/__init__.py | 3 +-- homeassistant/components/fan/zwave.py | 2 +- homeassistant/components/http/__init__.py | 4 ++-- homeassistant/components/http/ban.py | 4 ++-- homeassistant/components/http/const.py | 2 +- homeassistant/components/mqtt/__init__.py | 11 ++++------- homeassistant/helpers/aiohttp_client.py | 2 +- homeassistant/helpers/discovery.py | 2 +- homeassistant/helpers/dispatcher.py | 4 ++-- homeassistant/helpers/sun.py | 2 +- homeassistant/util/package.py | 5 +++-- homeassistant/util/unit_system.py | 6 +++--- 13 files changed, 27 insertions(+), 30 deletions(-) diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index 219d413db122..c02d8c8bfc6b 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -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) diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index 54c503c1b9f1..2a96a16bf558 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -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: diff --git a/homeassistant/components/fan/zwave.py b/homeassistant/components/fan/zwave.py index fe01ae5f3a42..364306ff8ddd 100644 --- a/homeassistant/components/fan/zwave.py +++ b/homeassistant/components/fan/zwave.py @@ -36,7 +36,7 @@ SPEED_TO_VALUE = { def get_device(values, **kwargs): - """Create zwave entity device.""" + """Create Z-Wave entity device.""" return ZwaveFan(values) diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http/__init__.py index dc5e59f4155b..d8647dea0c3a 100644 --- a/homeassistant/components/http/__init__.py +++ b/homeassistant/components/http/__init__.py @@ -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() diff --git a/homeassistant/components/http/ban.py b/homeassistant/components/http/ban.py index d2b9fa402ef9..aa01ccde8d76 100644 --- a/homeassistant/components/http/ban.py +++ b/homeassistant/components/http/ban.py @@ -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): diff --git a/homeassistant/components/http/const.py b/homeassistant/components/http/const.py index 625bc24c461f..5922042e4fb5 100644 --- a/homeassistant/components/http/const.py +++ b/homeassistant/components/http/const.py @@ -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' diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index f4b57f0c803a..16ac00e3b7b4 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -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(): diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 9aac258684f8..a8b18351021c 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -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. """ diff --git a/homeassistant/helpers/discovery.py b/homeassistant/helpers/discovery.py index 7d3d7d0e823a..c3e4b2b49422 100644 --- a/homeassistant/helpers/discovery.py +++ b/homeassistant/helpers/discovery.py @@ -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. """ diff --git a/homeassistant/helpers/dispatcher.py b/homeassistant/helpers/dispatcher.py index d5fbadec8830..a426f2de855f 100644 --- a/homeassistant/helpers/dispatcher.py +++ b/homeassistant/helpers/dispatcher.py @@ -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. """ diff --git a/homeassistant/helpers/sun.py b/homeassistant/helpers/sun.py index 157225c9903a..5ad4f06fdf1a 100644 --- a/homeassistant/helpers/sun.py +++ b/homeassistant/helpers/sun.py @@ -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 diff --git a/homeassistant/util/package.py b/homeassistant/util/package.py index ed533a3872fd..a5a863b08808 100644 --- a/homeassistant/util/package.py +++ b/homeassistant/util/package.py @@ -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 diff --git a/homeassistant/util/unit_system.py b/homeassistant/util/unit_system.py index ae3630c27a9c..31b76365da4f 100644 --- a/homeassistant/util/unit_system.py +++ b/homeassistant/util/unit_system.py @@ -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