From 106bf467f85aeceba55dc090fcf8a1142ddb43dc Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 22 Oct 2017 10:56:20 -0700 Subject: [PATCH 1/8] 0.56.1 (#10035) * Version bump to 0.56.1 * Fix device update / entity_id with names (#10029) * Fix device update * Add tests * add test for disabled warning * fix temperature/humidity sensors valid values (#10024) --- .../components/sensor/xiaomi_aqara.py | 8 +-- homeassistant/const.py | 2 +- homeassistant/helpers/entity.py | 58 +++++++++++-------- homeassistant/helpers/entity_component.py | 19 ++++-- tests/helpers/test_entity.py | 24 ++++++++ tests/helpers/test_entity_component.py | 45 +++++++------- 6 files changed, 99 insertions(+), 57 deletions(-) diff --git a/homeassistant/components/sensor/xiaomi_aqara.py b/homeassistant/components/sensor/xiaomi_aqara.py index 92b4e5b80b9..f375f1ba9ad 100644 --- a/homeassistant/components/sensor/xiaomi_aqara.py +++ b/homeassistant/components/sensor/xiaomi_aqara.py @@ -67,6 +67,10 @@ class XiaomiSensor(XiaomiDevice): if value is None: return False value = float(value) + if self._data_key in ['temperature', 'humidity', 'pressure']: + value /= 100 + elif self._data_key in ['illumination']: + value = max(value - 300, 0) if self._data_key == 'temperature' and (value < -20 or value > 60): return False elif self._data_key == 'humidity' and (value <= 0 or value > 100): @@ -75,9 +79,5 @@ class XiaomiSensor(XiaomiDevice): return False elif self._data_key == 'pressure' and value == 0: return False - if self._data_key in ['temperature', 'humidity', 'pressure']: - value /= 100 - elif self._data_key in ['illumination']: - value = max(value - 300, 0) self._state = round(value, 2) return True diff --git a/homeassistant/const.py b/homeassistant/const.py index ddb7114dbca..ca438f35102 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 56 -PATCH_VERSION = '0' +PATCH_VERSION = '1' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 4, 2) diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 930c76f9779..da82fc9202f 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -200,34 +200,11 @@ class Entity(object): # update entity data if force_refresh: - if self._update_staged: - return - self._update_staged = True - - # Process update sequential - if self.parallel_updates: - yield from self.parallel_updates.acquire() - - update_warn = self.hass.loop.call_later( - SLOW_UPDATE_WARNING, _LOGGER.warning, - "Update of %s is taking over %s seconds", self.entity_id, - SLOW_UPDATE_WARNING - ) - try: - if hasattr(self, 'async_update'): - # pylint: disable=no-member - yield from self.async_update() - else: - yield from self.hass.async_add_job(self.update) + yield from self.async_device_update() except Exception: # pylint: disable=broad-except _LOGGER.exception("Update for %s fails", self.entity_id) return - finally: - self._update_staged = False - update_warn.cancel() - if self.parallel_updates: - self.parallel_updates.release() start = timer() @@ -304,6 +281,39 @@ class Entity(object): """Schedule a update ha state change task.""" self.hass.async_add_job(self.async_update_ha_state(force_refresh)) + def async_device_update(self, warning=True): + """Process 'update' or 'async_update' from entity. + + This method is a coroutine. + """ + if self._update_staged: + return + self._update_staged = True + + # Process update sequential + if self.parallel_updates: + yield from self.parallel_updates.acquire() + + if warning: + update_warn = self.hass.loop.call_later( + SLOW_UPDATE_WARNING, _LOGGER.warning, + "Update of %s is taking over %s seconds", self.entity_id, + SLOW_UPDATE_WARNING + ) + + try: + if hasattr(self, 'async_update'): + # pylint: disable=no-member + yield from self.async_update() + else: + yield from self.hass.async_add_job(self.update) + finally: + self._update_staged = False + if warning: + update_warn.cancel() + if self.parallel_updates: + self.parallel_updates.release() + def remove(self) -> None: """Remove entity from HASS.""" run_coroutine_threadsafe( diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index 8a3026c49e5..e805f277483 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -210,6 +210,15 @@ class EntityComponent(object): entity.hass = self.hass + # Update properties before we generate the entity_id + if update_before_add: + try: + yield from entity.async_device_update(warning=False) + except Exception: # pylint: disable=broad-except + self.logger.exception("Error on device update!") + return False + + # Write entity_id to entity if getattr(entity, 'entity_id', None) is None: object_id = entity.name or DEVICE_DEFAULT_NAME @@ -234,7 +243,7 @@ class EntityComponent(object): if hasattr(entity, 'async_added_to_hass'): yield from entity.async_added_to_hass() - yield from entity.async_update_ha_state(update_before_add) + yield from entity.async_update_ha_state() return True @@ -361,12 +370,14 @@ class EntityPlatform(object): def add_entities(self, new_entities, update_before_add=False): """Add entities for a single platform.""" + # That avoid deadlocks if update_before_add: - for entity in new_entities: - entity.update() + self.component.logger.warning( + "Call 'add_entities' with update_before_add=True " + "only inside tests or you can run into a deadlock!") run_coroutine_threadsafe( - self.async_add_entities(list(new_entities), False), + self.async_add_entities(list(new_entities), update_before_add), self.component.hass.loop).result() @asyncio.coroutine diff --git a/tests/helpers/test_entity.py b/tests/helpers/test_entity.py index 56a696e1f1b..d7f518f489e 100644 --- a/tests/helpers/test_entity.py +++ b/tests/helpers/test_entity.py @@ -193,6 +193,30 @@ def test_warn_slow_update_with_exception(hass): assert update_call +@asyncio.coroutine +def test_warn_slow_device_update_disabled(hass): + """Disable slow update warning with async_device_update.""" + update_call = False + + @asyncio.coroutine + def async_update(): + """Mock async update.""" + nonlocal update_call + update_call = True + + mock_entity = entity.Entity() + mock_entity.hass = hass + mock_entity.entity_id = 'comp_test.test_entity' + mock_entity.async_update = async_update + + with patch.object(hass.loop, 'call_later', MagicMock()) \ + as mock_call: + yield from mock_entity.async_device_update(warning=False) + + assert not mock_call.called + assert update_call + + @asyncio.coroutine def test_async_schedule_update_ha_state(hass): """Warn we log when entity update takes a long time and trow exception.""" diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index 462d57160c9..6a00978fbe4 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -208,30 +208,6 @@ class TestHelpersEntityComponent(unittest.TestCase): assert 1 == len(self.hass.states.entity_ids()) assert not ent.update.called - def test_adds_entities_with_update_befor_add_true_deadlock_protect(self): - """Test if call update before add to state machine. - - It need to run update inside executor and never call - async_add_entities with True - """ - call = [] - component = EntityComponent(_LOGGER, DOMAIN, self.hass) - - @asyncio.coroutine - def async_add_entities_fake(entities, update_befor_add): - """Fake add_entities_call.""" - call.append(update_befor_add) - component._platforms['core'].async_add_entities = \ - async_add_entities_fake - - ent = EntityTest() - ent.update = Mock(spec_set=True) - component.add_entities([ent], True) - - assert ent.update.called - assert len(call) == 1 - assert not call[0] - def test_not_adding_duplicate_entities(self): """Test for not adding duplicate entities.""" component = EntityComponent(_LOGGER, DOMAIN, self.hass) @@ -654,3 +630,24 @@ def test_pararell_updates_sync_platform(hass): handle = list(component._platforms.values())[-1] assert handle.parallel_updates is not None + + +@asyncio.coroutine +def test_raise_error_on_update(hass): + """Test the add entity if they raise an error on update.""" + updates = [] + component = EntityComponent(_LOGGER, DOMAIN, hass) + entity1 = EntityTest(name='test_1') + entity2 = EntityTest(name='test_2') + + def _raise(): + """Helper to raise a exception.""" + raise AssertionError + + entity1.update = _raise + entity2.update = lambda: updates.append(1) + + yield from component.async_add_entities([entity1, entity2], True) + + assert len(updates) == 1 + assert 1 in updates From 48c86e07faf63d03644a211a0d2ea2290a7576b3 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Mon, 23 Oct 2017 08:02:20 +0200 Subject: [PATCH 2/8] fix gateway illumination sensor value (#10045) --- homeassistant/components/sensor/xiaomi_aqara.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/homeassistant/components/sensor/xiaomi_aqara.py b/homeassistant/components/sensor/xiaomi_aqara.py index f375f1ba9ad..7b771e8c785 100644 --- a/homeassistant/components/sensor/xiaomi_aqara.py +++ b/homeassistant/components/sensor/xiaomi_aqara.py @@ -75,8 +75,6 @@ class XiaomiSensor(XiaomiDevice): return False elif self._data_key == 'humidity' and (value <= 0 or value > 100): return False - elif self._data_key == 'illumination' and value == 0: - return False elif self._data_key == 'pressure' and value == 0: return False self._state = round(value, 2) From ed82f23da38f9663f55b32f05046b235bf5da9bd Mon Sep 17 00:00:00 2001 From: Teemu R Date: Mon, 23 Oct 2017 09:41:47 +0200 Subject: [PATCH 3/8] switch.tplink: fix overlooked issue with statically defined names (#10053) --- homeassistant/components/switch/tplink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/switch/tplink.py b/homeassistant/components/switch/tplink.py index df0050ff979..8fa6493862c 100644 --- a/homeassistant/components/switch/tplink.py +++ b/homeassistant/components/switch/tplink.py @@ -45,7 +45,7 @@ class SmartPlugSwitch(SwitchDevice): def __init__(self, smartplug, name): """Initialize the switch.""" self.smartplug = smartplug - self._name = None + self._name = name self._state = None # Set up emeter cache self._emeter_params = {} From 97943361135b54b1a8595b6e92b9849d09db7eda Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 23 Oct 2017 08:58:02 +0200 Subject: [PATCH 4/8] Remove warning --- homeassistant/helpers/entity_component.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index e805f277483..f6e9c1da7f8 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -370,12 +370,6 @@ class EntityPlatform(object): def add_entities(self, new_entities, update_before_add=False): """Add entities for a single platform.""" - # That avoid deadlocks - if update_before_add: - self.component.logger.warning( - "Call 'add_entities' with update_before_add=True " - "only inside tests or you can run into a deadlock!") - run_coroutine_threadsafe( self.async_add_entities(list(new_entities), update_before_add), self.component.hass.loop).result() From 32f58baa854048edc0bf089a8d380c7bafed8693 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 23 Oct 2017 13:49:04 +0200 Subject: [PATCH 5/8] Fix merge conflict --- homeassistant/components/automation/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/automation/event.py b/homeassistant/components/automation/event.py index 90baeaded14..d8c32fde86d 100644 --- a/homeassistant/components/automation/event.py +++ b/homeassistant/components/automation/event.py @@ -31,7 +31,7 @@ def async_trigger(hass, config, action): event_type = config.get(CONF_EVENT_TYPE) event_data_schema = vol.Schema( config.get(CONF_EVENT_DATA), - extra=vol.ALLOW_EXTRA) + extra=vol.ALLOW_EXTRA) if config.get(CONF_EVENT_DATA) else None @callback def handle_event(event): From 79d71c6727eb05e7d332fcde824118f289d53d26 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 23 Oct 2017 13:50:11 +0200 Subject: [PATCH 6/8] Version bump to 0.56.2 --- homeassistant/components/automation/event.py | 11 ++++++----- homeassistant/const.py | 2 +- homeassistant/helpers/entity_component.py | 6 ++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/automation/event.py b/homeassistant/components/automation/event.py index d8c32fde86d..6f750245df9 100644 --- a/homeassistant/components/automation/event.py +++ b/homeassistant/components/automation/event.py @@ -36,11 +36,12 @@ def async_trigger(hass, config, action): @callback def handle_event(event): """Listen for events and calls the action when data matches.""" - try: - event_data_schema(event.data) - except vol.Invalid: - # If event data doesn't match requested schema, skip event - return + if event_data_schema: + try: + event_data_schema(event.data) + except vol.Invalid: + # If event data doesn't match requested schema, skip event + return hass.async_run_job(action, { 'trigger': { diff --git a/homeassistant/const.py b/homeassistant/const.py index ca438f35102..3a2ee824dda 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 56 -PATCH_VERSION = '1' +PATCH_VERSION = '2' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 4, 2) diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index f6e9c1da7f8..e805f277483 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -370,6 +370,12 @@ class EntityPlatform(object): def add_entities(self, new_entities, update_before_add=False): """Add entities for a single platform.""" + # That avoid deadlocks + if update_before_add: + self.component.logger.warning( + "Call 'add_entities' with update_before_add=True " + "only inside tests or you can run into a deadlock!") + run_coroutine_threadsafe( self.async_add_entities(list(new_entities), update_before_add), self.component.hass.loop).result() From 8e4f0ea5aec36879dcd58b4161161714d6d9d41c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 27 Oct 2017 21:50:22 +0200 Subject: [PATCH 7/8] Upgrade restrictedpython to 4.0b2 --- homeassistant/components/python_script.py | 44 +++++++++++++---------- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/python_script.py b/homeassistant/components/python_script.py index 6bf677b9645..aeac262881d 100644 --- a/homeassistant/components/python_script.py +++ b/homeassistant/components/python_script.py @@ -1,4 +1,9 @@ -"""Component to allow running Python scripts.""" +""" +Component to allow running Python scripts. + +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/python_script/ +""" import datetime import glob import logging @@ -7,16 +12,19 @@ import time import voluptuous as vol +import homeassistant.util.dt as dt_util from homeassistant.const import SERVICE_RELOAD from homeassistant.exceptions import HomeAssistantError from homeassistant.loader import bind_hass from homeassistant.util import sanitize_filename -import homeassistant.util.dt as dt_util + +REQUIREMENTS = ['restrictedpython==4.0b2'] + +_LOGGER = logging.getLogger(__name__) DOMAIN = 'python_script' -REQUIREMENTS = ['restrictedpython==4.0a3'] + FOLDER = 'python_scripts' -_LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema(dict) @@ -47,7 +55,7 @@ def setup(hass, config): path = hass.config.path(FOLDER) if not os.path.isdir(path): - _LOGGER.warning('Folder %s not found in config folder', FOLDER) + _LOGGER.warning("Folder %s not found in configuration folder", FOLDER) return False discover_scripts(hass) @@ -65,7 +73,7 @@ def discover_scripts(hass): path = hass.config.path(FOLDER) if not os.path.isdir(path): - _LOGGER.warning('Folder %s not found in config folder', FOLDER) + _LOGGER.warning("Folder %s not found in configuration folder", FOLDER) return False def python_script_service_handler(call): @@ -104,19 +112,19 @@ def execute(hass, filename, source, data=None): compiled = compile_restricted_exec(source, filename=filename) if compiled.errors: - _LOGGER.error('Error loading script %s: %s', filename, - ', '.join(compiled.errors)) + _LOGGER.error("Error loading script %s: %s", filename, + ", ".join(compiled.errors)) return if compiled.warnings: - _LOGGER.warning('Warning loading script %s: %s', filename, - ', '.join(compiled.warnings)) + _LOGGER.warning("Warning loading script %s: %s", filename, + ", ".join(compiled.warnings)) def protected_getattr(obj, name, default=None): """Restricted method to get attributes.""" # pylint: disable=too-many-boolean-expressions if name.startswith('async_'): - raise ScriptError('Not allowed to access async methods') + raise ScriptError("Not allowed to access async methods") elif (obj is hass and name not in ALLOWED_HASS or obj is hass.bus and name not in ALLOWED_EVENTBUS or obj is hass.states and name not in ALLOWED_STATEMACHINE or @@ -124,7 +132,7 @@ def execute(hass, filename, source, data=None): obj is dt_util and name not in ALLOWED_DT_UTIL or obj is datetime and name not in ALLOWED_DATETIME or isinstance(obj, TimeWrapper) and name not in ALLOWED_TIME): - raise ScriptError('Not allowed to access {}.{}'.format( + raise ScriptError("Not allowed to access {}.{}".format( obj.__class__.__name__, name)) return getattr(obj, name, default) @@ -152,13 +160,13 @@ def execute(hass, filename, source, data=None): } try: - _LOGGER.info('Executing %s: %s', filename, data) + _LOGGER.info("Executing %s: %s", filename, data) # pylint: disable=exec-used exec(compiled.code, restricted_globals, local) except ScriptError as err: - logger.error('Error executing script: %s', err) + logger.error("Error executing script: %s", err) except Exception as err: # pylint: disable=broad-except - logger.exception('Error executing script: %s', err) + logger.exception("Error executing script: %s", err) class StubPrinter: @@ -172,7 +180,7 @@ class StubPrinter: """Print text.""" # pylint: disable=no-self-use _LOGGER.warning( - "Don't use print() inside scripts. Use logger.info() instead.") + "Don't use print() inside scripts. Use logger.info() instead") class TimeWrapper: @@ -186,8 +194,8 @@ class TimeWrapper: """Sleep method that warns once.""" if not TimeWrapper.warned: TimeWrapper.warned = True - _LOGGER.warning('Using time.sleep can reduce the performance of ' - 'Home Assistant') + _LOGGER.warning("Using time.sleep can reduce the performance of " + "Home Assistant") time.sleep(*args, **kwargs) diff --git a/requirements_all.txt b/requirements_all.txt index 985d9d539cd..b37977efc38 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -894,7 +894,7 @@ raincloudy==0.0.3 regenmaschine==0.4.1 # homeassistant.components.python_script -restrictedpython==4.0a3 +restrictedpython==4.0b2 # homeassistant.components.rflink rflink==0.0.34 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index cdd6a55bc0c..d1c324b5d65 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -124,7 +124,7 @@ pyunifi==2.13 pywebpush==1.1.0 # homeassistant.components.python_script -restrictedpython==4.0a3 +restrictedpython==4.0b2 # homeassistant.components.rflink rflink==0.0.34 From 38c189ecf41787602c0823c6aeb09588e594ec73 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 27 Oct 2017 21:52:44 +0200 Subject: [PATCH 8/8] Revert "Upgrade restrictedpython to 4.0b2" This reverts commit 8e4f0ea5aec36879dcd58b4161161714d6d9d41c. --- homeassistant/components/python_script.py | 44 ++++++++++------------- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/homeassistant/components/python_script.py b/homeassistant/components/python_script.py index aeac262881d..6bf677b9645 100644 --- a/homeassistant/components/python_script.py +++ b/homeassistant/components/python_script.py @@ -1,9 +1,4 @@ -""" -Component to allow running Python scripts. - -For more details about this component, please refer to the documentation at -https://home-assistant.io/components/python_script/ -""" +"""Component to allow running Python scripts.""" import datetime import glob import logging @@ -12,19 +7,16 @@ import time import voluptuous as vol -import homeassistant.util.dt as dt_util from homeassistant.const import SERVICE_RELOAD from homeassistant.exceptions import HomeAssistantError from homeassistant.loader import bind_hass from homeassistant.util import sanitize_filename - -REQUIREMENTS = ['restrictedpython==4.0b2'] - -_LOGGER = logging.getLogger(__name__) +import homeassistant.util.dt as dt_util DOMAIN = 'python_script' - +REQUIREMENTS = ['restrictedpython==4.0a3'] FOLDER = 'python_scripts' +_LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema(dict) @@ -55,7 +47,7 @@ def setup(hass, config): path = hass.config.path(FOLDER) if not os.path.isdir(path): - _LOGGER.warning("Folder %s not found in configuration folder", FOLDER) + _LOGGER.warning('Folder %s not found in config folder', FOLDER) return False discover_scripts(hass) @@ -73,7 +65,7 @@ def discover_scripts(hass): path = hass.config.path(FOLDER) if not os.path.isdir(path): - _LOGGER.warning("Folder %s not found in configuration folder", FOLDER) + _LOGGER.warning('Folder %s not found in config folder', FOLDER) return False def python_script_service_handler(call): @@ -112,19 +104,19 @@ def execute(hass, filename, source, data=None): compiled = compile_restricted_exec(source, filename=filename) if compiled.errors: - _LOGGER.error("Error loading script %s: %s", filename, - ", ".join(compiled.errors)) + _LOGGER.error('Error loading script %s: %s', filename, + ', '.join(compiled.errors)) return if compiled.warnings: - _LOGGER.warning("Warning loading script %s: %s", filename, - ", ".join(compiled.warnings)) + _LOGGER.warning('Warning loading script %s: %s', filename, + ', '.join(compiled.warnings)) def protected_getattr(obj, name, default=None): """Restricted method to get attributes.""" # pylint: disable=too-many-boolean-expressions if name.startswith('async_'): - raise ScriptError("Not allowed to access async methods") + raise ScriptError('Not allowed to access async methods') elif (obj is hass and name not in ALLOWED_HASS or obj is hass.bus and name not in ALLOWED_EVENTBUS or obj is hass.states and name not in ALLOWED_STATEMACHINE or @@ -132,7 +124,7 @@ def execute(hass, filename, source, data=None): obj is dt_util and name not in ALLOWED_DT_UTIL or obj is datetime and name not in ALLOWED_DATETIME or isinstance(obj, TimeWrapper) and name not in ALLOWED_TIME): - raise ScriptError("Not allowed to access {}.{}".format( + raise ScriptError('Not allowed to access {}.{}'.format( obj.__class__.__name__, name)) return getattr(obj, name, default) @@ -160,13 +152,13 @@ def execute(hass, filename, source, data=None): } try: - _LOGGER.info("Executing %s: %s", filename, data) + _LOGGER.info('Executing %s: %s', filename, data) # pylint: disable=exec-used exec(compiled.code, restricted_globals, local) except ScriptError as err: - logger.error("Error executing script: %s", err) + logger.error('Error executing script: %s', err) except Exception as err: # pylint: disable=broad-except - logger.exception("Error executing script: %s", err) + logger.exception('Error executing script: %s', err) class StubPrinter: @@ -180,7 +172,7 @@ class StubPrinter: """Print text.""" # pylint: disable=no-self-use _LOGGER.warning( - "Don't use print() inside scripts. Use logger.info() instead") + "Don't use print() inside scripts. Use logger.info() instead.") class TimeWrapper: @@ -194,8 +186,8 @@ class TimeWrapper: """Sleep method that warns once.""" if not TimeWrapper.warned: TimeWrapper.warned = True - _LOGGER.warning("Using time.sleep can reduce the performance of " - "Home Assistant") + _LOGGER.warning('Using time.sleep can reduce the performance of ' + 'Home Assistant') time.sleep(*args, **kwargs) diff --git a/requirements_all.txt b/requirements_all.txt index b37977efc38..985d9d539cd 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -894,7 +894,7 @@ raincloudy==0.0.3 regenmaschine==0.4.1 # homeassistant.components.python_script -restrictedpython==4.0b2 +restrictedpython==4.0a3 # homeassistant.components.rflink rflink==0.0.34 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index d1c324b5d65..cdd6a55bc0c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -124,7 +124,7 @@ pyunifi==2.13 pywebpush==1.1.0 # homeassistant.components.python_script -restrictedpython==4.0b2 +restrictedpython==4.0a3 # homeassistant.components.rflink rflink==0.0.34