当前位置: 首页>>代码示例>>Python>>正文


Python googleapiclient.errors方法代码示例

本文整理汇总了Python中googleapiclient.errors方法的典型用法代码示例。如果您正苦于以下问题:Python googleapiclient.errors方法的具体用法?Python googleapiclient.errors怎么用?Python googleapiclient.errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在googleapiclient的用法示例。


在下文中一共展示了googleapiclient.errors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: retry_auth_check

# 需要导入模块: import googleapiclient [as 别名]
# 或者: from googleapiclient import errors [as 别名]
def retry_auth_check(exception, verbose):
  """Specific check for auth error codes.

  Return True if we should retry.

  False otherwise.
  Args:
    exception: An exception to test for transience.
    verbose: If true, output retry messages

  Returns:
    True if we should retry. False otherwise.
  """
  if isinstance(exception, googleapiclient.errors.HttpError):
    if exception.resp.status in HTTP_AUTH_ERROR_CODES:
      _print_retry_error(exception, verbose)
      return True

  return False 
开发者ID:DataBiosphere,项目名称:dsub,代码行数:21,代码来源:google_base.py

示例2: _load_credentials

# 需要导入模块: import googleapiclient [as 别名]
# 或者: from googleapiclient import errors [as 别名]
def _load_credentials(cls, keydata):
        """Load ServiceAccountCredentials from Google service account JSON keyfile

        Args:
            keydata (dict): The loaded keyfile data from a Google service account
                JSON file

        Returns:
             google.oauth2.service_account.ServiceAccountCredentials: Instance of
                service account credentials for this discovery service
        """
        try:
            creds = service_account.Credentials.from_service_account_info(
                keydata,
                scopes=cls._SCOPES,
            )
        except (ValueError, KeyError):
            # This has the potential to raise errors. See: https://tinyurl.com/y8q5e9rm
            LOGGER.exception('[%s] Could not generate credentials from keyfile', cls.type())
            return False

        return creds 
开发者ID:airbnb,项目名称:streamalert,代码行数:24,代码来源:gsuite.py

示例3: wait_for_completion

# 需要导入模块: import googleapiclient [as 别名]
# 或者: from googleapiclient import errors [as 别名]
def wait_for_completion(projectId, jobId):
    """ Make requests periodically until the passed job has been completed """

    while True:

        try:
            job = bigquery.jobs().get(projectId=projectId, jobId=jobId).execute(num_retries=5)
        except googleapiclient.errors.HttpError as err:
            current_app.logger.error("HttpError while waiting for completion of job: {}".format(err), exc_info=True)
            time.sleep(JOB_COMPLETION_CHECK_DELAY)
            continue

        if job["status"]["state"] == "DONE":
            return
        else:
            time.sleep(JOB_COMPLETION_CHECK_DELAY) 
开发者ID:metabrainz,项目名称:listenbrainz-server,代码行数:18,代码来源:__init__.py

示例4: _create_service

# 需要导入模块: import googleapiclient [as 别名]
# 或者: from googleapiclient import errors [as 别名]
def _create_service(self):
        """GSuite requests must be signed with the keyfile

        Returns:
            bool: True if the Google API discovery service was successfully established or False
                if any errors occurred during the creation of the Google discovery service,
        """
        LOGGER.debug('[%s] Creating activities service', self)

        if self._activities_service:
            LOGGER.debug('[%s] Service already instantiated', self)
            return True

        creds = self._load_credentials(self._config.auth['keyfile'])
        if not creds:
            return False

        delegation = creds.with_subject(self._config.auth['delegation_email'])
        try:
            resource = googleapiclient.discovery.build(
                'admin',
                'reports_v1',
                credentials=delegation
            )
        except self._GOOGLE_API_EXCEPTIONS:
            LOGGER.exception('[%s] Failed to build discovery service', self)
            return False

        # The google discovery service 'Resource' class that is returned by
        # 'discovery.build' dynamically loads methods/attributes, so pylint will complain
        # about no 'activities' member existing without the below pylint comment
        self._activities_service = resource.activities()  # pylint: disable=no-member

        return True 
开发者ID:airbnb,项目名称:streamalert,代码行数:36,代码来源:gsuite.py

示例5: retry_api_check

# 需要导入模块: import googleapiclient [as 别名]
# 或者: from googleapiclient import errors [as 别名]
def retry_api_check(exception, verbose):
  """Return True if we should retry. False otherwise.

  Args:
    exception: An exception to test for transience.
    verbose: If true, output retry messages

  Returns:
    True if we should retry. False otherwise.
  """
  if isinstance(exception, googleapiclient.errors.HttpError):
    if exception.resp.status in TRANSIENT_HTTP_ERROR_CODES:
      _print_retry_error(exception, verbose)
      return True

  if isinstance(exception, socket.error):
    if exception.errno in TRANSIENT_SOCKET_ERROR_CODES:
      _print_retry_error(exception, verbose)
      return True

  if isinstance(exception, google.auth.exceptions.RefreshError):
    _print_retry_error(exception, verbose)
    return True

  # For a given installation, this could be a permanent error, but has only
  # been observed as transient.
  if isinstance(exception, ssl.SSLError):
    _print_retry_error(exception, verbose)
    return True

  # This has been observed as a transient error:
  #   ServerNotFoundError: Unable to find the server at genomics.googleapis.com
  if isinstance(exception, ServerNotFoundError):
    _print_retry_error(exception, verbose)
    return True

  # Observed to be thrown transiently from auth libraries which use httplib2
  # Use the one from six because httlib no longer exists in Python3
  # https://docs.python.org/2/library/httplib.html
  if isinstance(exception, six.moves.http_client.ResponseNotReady):
    _print_retry_error(exception, verbose)
    return True

  return False 
开发者ID:DataBiosphere,项目名称:dsub,代码行数:46,代码来源:google_base.py


注:本文中的googleapiclient.errors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。