Convert more files to async/await syntax (#14142)
* Move more files to async/await syntax * Attempt Work around pylint bug Using lazytox :P
This commit is contained in:
1 parent
a0b14c2913
commit
a4bf421044
27 files changed
+229
-327
No files matched your search
@@ -4,7 +4,6 @@ Support for Dialogflow webhook.
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/dialogflow/
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
@@ -37,8 +36,7 @@ class DialogFlowError(HomeAssistantError):
|
||||
"""Raised when a DialogFlow error happens."""
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup(hass, config):
|
||||
async def async_setup(hass, config):
|
||||
"""Set up Dialogflow component."""
|
||||
hass.http.register_view(DialogflowIntentsView)
|
||||
|
||||
@@ -51,16 +49,15 @@ class DialogflowIntentsView(HomeAssistantView):
|
||||
url = INTENTS_API_ENDPOINT
|
||||
name = 'api:dialogflow'
|
||||
|
||||
@asyncio.coroutine
|
||||
def post(self, request):
|
||||
async def post(self, request):
|
||||
"""Handle Dialogflow."""
|
||||
hass = request.app['hass']
|
||||
message = yield from request.json()
|
||||
message = await request.json()
|
||||
|
||||
_LOGGER.debug("Received Dialogflow request: %s", message)
|
||||
|
||||
try:
|
||||
response = yield from async_handle_message(hass, message)
|
||||
response = await async_handle_message(hass, message)
|
||||
return b'' if response is None else self.json(response)
|
||||
|
||||
except DialogFlowError as err:
|
||||
@@ -93,8 +90,7 @@ def dialogflow_error_response(hass, message, error):
|
||||
return dialogflow_response.as_dict()
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_handle_message(hass, message):
|
||||
async def async_handle_message(hass, message):
|
||||
"""Handle a DialogFlow message."""
|
||||
req = message.get('result')
|
||||
action_incomplete = req['actionIncomplete']
|
||||
@@ -110,7 +106,7 @@ def async_handle_message(hass, message):
|
||||
raise DialogFlowError(
|
||||
"You have not defined an action in your Dialogflow intent.")
|
||||
|
||||
intent_response = yield from intent.async_handle(
|
||||
intent_response = await intent.async_handle(
|
||||
hass, DOMAIN, action,
|
||||
{key: {'value': value} for key, value
|
||||
in parameters.items()})
|
||||
|
||||
Reference in new issue
Block a user