mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Move imports in google component (#27826)
This commit is contained in:
parent
6998687742
commit
61edd33da7
@ -4,6 +4,15 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
import httplib2
|
||||||
|
from oauth2client.client import (
|
||||||
|
OAuth2WebServerFlow,
|
||||||
|
OAuth2DeviceCodeError,
|
||||||
|
FlowExchangeError,
|
||||||
|
)
|
||||||
|
from oauth2client.file import Storage
|
||||||
|
from googleapiclient import discovery as google_discovery
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from voluptuous.error import Error as VoluptuousError
|
from voluptuous.error import Error as VoluptuousError
|
||||||
|
|
||||||
@ -126,13 +135,6 @@ def do_authentication(hass, hass_config, config):
|
|||||||
Notify user of user_code and verification_url then poll
|
Notify user of user_code and verification_url then poll
|
||||||
until we have an access token.
|
until we have an access token.
|
||||||
"""
|
"""
|
||||||
from oauth2client.client import (
|
|
||||||
OAuth2WebServerFlow,
|
|
||||||
OAuth2DeviceCodeError,
|
|
||||||
FlowExchangeError,
|
|
||||||
)
|
|
||||||
from oauth2client.file import Storage
|
|
||||||
|
|
||||||
oauth = OAuth2WebServerFlow(
|
oauth = OAuth2WebServerFlow(
|
||||||
client_id=config[CONF_CLIENT_ID],
|
client_id=config[CONF_CLIENT_ID],
|
||||||
client_secret=config[CONF_CLIENT_SECRET],
|
client_secret=config[CONF_CLIENT_SECRET],
|
||||||
@ -341,10 +343,6 @@ class GoogleCalendarService:
|
|||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Get the calendar service from the storage file token."""
|
"""Get the calendar service from the storage file token."""
|
||||||
import httplib2
|
|
||||||
from oauth2client.file import Storage
|
|
||||||
from googleapiclient import discovery as google_discovery
|
|
||||||
|
|
||||||
credentials = Storage(self.token_file).get()
|
credentials = Storage(self.token_file).get()
|
||||||
http = credentials.authorize(httplib2.Http())
|
http = credentials.authorize(httplib2.Http())
|
||||||
service = google_discovery.build(
|
service = google_discovery.build(
|
||||||
|
@ -3,6 +3,8 @@ import copy
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from httplib2 import ServerNotFoundError # pylint: disable=import-error
|
||||||
|
|
||||||
from homeassistant.components.calendar import (
|
from homeassistant.components.calendar import (
|
||||||
ENTITY_ID_FORMAT,
|
ENTITY_ID_FORMAT,
|
||||||
CalendarEventDevice,
|
CalendarEventDevice,
|
||||||
@ -126,9 +128,6 @@ class GoogleCalendarData:
|
|||||||
self.event = None
|
self.event = None
|
||||||
|
|
||||||
def _prepare_query(self):
|
def _prepare_query(self):
|
||||||
# pylint: disable=import-error
|
|
||||||
from httplib2 import ServerNotFoundError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service = self.calendar_service.get()
|
service = self.calendar_service.get()
|
||||||
except ServerNotFoundError:
|
except ServerNotFoundError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user