Move imports to top for python_script (#29331)
This commit is contained in:
parent
5a24dbf599
commit
8baba2e33d
1 changed files with 10 additions and 10 deletions
|
@ -5,6 +5,15 @@ import logging
|
|||
import os
|
||||
import time
|
||||
|
||||
from RestrictedPython import compile_restricted_exec
|
||||
from RestrictedPython.Eval import default_guarded_getitem
|
||||
from RestrictedPython.Guards import (
|
||||
full_write_guard,
|
||||
guarded_iter_unpack_sequence,
|
||||
guarded_unpack_sequence,
|
||||
safe_builtins,
|
||||
)
|
||||
from RestrictedPython.Utilities import utility_builtins
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import SERVICE_RELOAD
|
||||
|
@ -12,8 +21,8 @@ from homeassistant.exceptions import HomeAssistantError
|
|||
from homeassistant.helpers.service import async_set_service_schema
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.util import sanitize_filename
|
||||
from homeassistant.util.yaml.loader import load_yaml
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.util.yaml.loader import load_yaml
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -122,15 +131,6 @@ def execute_script(hass, name, data=None):
|
|||
@bind_hass
|
||||
def execute(hass, filename, source, data=None):
|
||||
"""Execute Python source."""
|
||||
from RestrictedPython import compile_restricted_exec
|
||||
from RestrictedPython.Guards import (
|
||||
safe_builtins,
|
||||
full_write_guard,
|
||||
guarded_iter_unpack_sequence,
|
||||
guarded_unpack_sequence,
|
||||
)
|
||||
from RestrictedPython.Utilities import utility_builtins
|
||||
from RestrictedPython.Eval import default_guarded_getitem
|
||||
|
||||
compiled = compile_restricted_exec(source, filename=filename)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue