From e136b0d82218bbe91c3d9f16d2187752289e27e6 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Thu, 7 Mar 2019 15:32:28 +0100 Subject: [PATCH] Fix py3 issue on fernet-manage and update-endpoint fernet-manage: - filter used to return a list on python2 but on python3 it returns an iterator which has no len method - Coherce the keys var into a list so we can run len on it on both versions update-endpoint: - ConfigParser is called configparser on python3 - try/catch and import the proper configparser Change-Id: I8296074f4d20e47afe0c7aea41bf21999685aecd --- keystone/templates/bin/_endpoint-update.py.tpl | 5 ++++- keystone/templates/bin/_fernet-manage.py.tpl | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/keystone/templates/bin/_endpoint-update.py.tpl b/keystone/templates/bin/_endpoint-update.py.tpl index f523c6269b..62794f836d 100644 --- a/keystone/templates/bin/_endpoint-update.py.tpl +++ b/keystone/templates/bin/_endpoint-update.py.tpl @@ -17,7 +17,10 @@ limitations under the License. #!/usr/bin/env python import os import sys -import ConfigParser +try: + import ConfigParser +except ImportError: + import configparser as ConfigParser import logging from sqlalchemy import create_engine diff --git a/keystone/templates/bin/_fernet-manage.py.tpl b/keystone/templates/bin/_fernet-manage.py.tpl index a5ea3d6fa0..3fdc1b40b9 100644 --- a/keystone/templates/bin/_fernet-manage.py.tpl +++ b/keystone/templates/bin/_fernet-manage.py.tpl @@ -91,7 +91,7 @@ def read_from_files(): for key in keys: with open(FERNET_DIR + key, 'r') as f: data[key] = f.read() - if len(keys): + if len(list(keys)): LOG.debug("Keys read from files: %s", keys) else: LOG.warn("No keys were read from files.")