Skip to content

Incorrect logging level for oauth2client.contrib.locked_file (ref #427) #873

@quasipedia

Description

@quasipedia

This is - as per request in the original #427 - a follow-up issue.

The function documentation says:

Detects an appropriate cache module and returns it. Returns googleapiclient.discovery_cache.base.Cache, a cache object which is auto detected, or None if no cache object is available.

Exceptions in this context only provide a pythonic way to do control flow, and do not indicate anomalies or malfunctioning of the code. None is a perfectly fine, as-per-specifications behaviour. The correct level should probably be INFO.

Also, even if you would stand by the WARNING level, you should tidy up the messy log message. This is what the user is met with:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
    from google.appengine.api import memcache
ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 42, in autodetect
    from . import file_cache
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth

A saner way to to communicate with the user could potentially be:

WARNING - No caching available (file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth)

Metadata

Metadata

Assignees

Labels

type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions