__main__.py 文件源码

python
阅读 46 收藏 0 点赞 0 评论 0

项目:mocktailsmixer 作者: Deeplocal 项目源码 文件源码
def setup_assistant():

    # Load credentials.
    try:
      credentials = os.path.join(
          click.get_app_dir(common_settings.ASSISTANT_APP_NAME),
          common_settings.ASSISTANT_CREDENTIALS_FILENAME
      )
      global creds
      creds = auth_helpers.load_credentials(credentials, scopes=[common_settings.ASSISTANT_OAUTH_SCOPE, common_settings.PUBSUB_OAUTH_SCOPE])
    except Exception as e:
      logging.error('Error loading credentials: %s', e)
      logging.error('Run auth_helpers to initialize new OAuth2 credentials.')
      return -1

    # Create gRPC channel
    grpc_channel = auth_helpers.create_grpc_channel(ASSISTANT_API_ENDPOINT, creds)
    logging.info('Connecting to %s', ASSISTANT_API_ENDPOINT)

    # Create Google Assistant API gRPC client.
    global assistant
    assistant = embedded_assistant_pb2.EmbeddedAssistantStub(grpc_channel)
    return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号