Only conditionally import working keyring
keyring is conditionally imported if available on your platform, however not all versions of keyring actually work. Specifically we have global-requirements of >=2.1,!=3.3, so we know those are the only versions we believe work. If you are on an older platform, using system installed python-keyring, python-keystoneclient won't install a new version, because it's optional, but then will use a terriblely old verison, which explodes with dbus errors. The fix is to be more explicit on import. Change-Id: I040f7b2311d7d5a450b8b12642752ac519b206fa Closes-Bug: #1242992
This commit is contained in:
@@ -20,14 +20,26 @@ OpenStack Client interface. Handles the REST calls and responses.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
# NOTE(sdague): The conditional keyring import needs to only
|
||||||
|
# trigger if it's a version of keyring that's supported in global
|
||||||
|
# requirements. Update _min and _bad when that changes.
|
||||||
|
keyring_v = pkg_resources.parse_version(
|
||||||
|
pkg_resources.get_distribution("keyring").version)
|
||||||
|
keyring_min = pkg_resources.parse_version('2.1')
|
||||||
|
keyring_bad = (pkg_resources.parse_version('3.3'),)
|
||||||
|
|
||||||
|
if keyring_v >= keyring_min and keyring_v not in keyring_bad:
|
||||||
import keyring
|
import keyring
|
||||||
except ImportError:
|
else:
|
||||||
|
keyring = None
|
||||||
|
except (ImportError, pkg_resources.DistributionNotFound):
|
||||||
keyring = None
|
keyring = None
|
||||||
pickle = None
|
pickle = None
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user