Fix open-ui cli arg (#26091)

* Fix open-ui cli command

* Align add_job typing with async_add_job
pull/26097/head
Paulus Schoutsen 2019-08-20 12:43:50 -07:00 committed by Pascal Vizeli
parent f34b84a5cf
commit 5c91a6cd48
2 changed files with 5 additions and 23 deletions

View File

@ -10,12 +10,7 @@ import threading
from typing import List, Dict, Any, TYPE_CHECKING # noqa pylint: disable=unused-import
from homeassistant import monkey_patch
from homeassistant.const import (
__version__,
EVENT_HOMEASSISTANT_START,
REQUIRED_PYTHON_VER,
RESTART_EXIT_CODE,
)
from homeassistant.const import __version__, REQUIRED_PYTHON_VER, RESTART_EXIT_CODE
if TYPE_CHECKING:
from homeassistant import core
@ -309,23 +304,10 @@ async def setup_and_run_hass(config_dir: str, args: argparse.Namespace) -> int:
log_no_color=args.log_no_color,
)
if args.open_ui:
# Imported here to avoid importing asyncio before monkey patch
from homeassistant.util.async_ import run_callback_threadsafe
if args.open_ui and hass.config.api is not None:
import webbrowser
def open_browser(_: Any) -> None:
"""Open the web interface in a browser."""
if hass.config.api is not None:
import webbrowser
webbrowser.open(hass.config.api.base_url)
run_callback_threadsafe(
hass.loop,
hass.bus.async_listen_once,
EVENT_HOMEASSISTANT_START,
open_browser,
)
hass.add_job(webbrowser.open, hass.config.api.base_url)
return await hass.async_run()

View File

@ -276,7 +276,7 @@ class HomeAssistant:
self.state = CoreState.running
_async_create_timer(self)
def add_job(self, target: Callable[..., None], *args: Any) -> None:
def add_job(self, target: Callable[..., Any], *args: Any) -> None:
"""Add job to the executor pool.
target: target to call.