Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Depends-On: https://review.opendev.org/722854 Change-Id: I190f32b2eea20024c71fc74bac7f5d011768473c
This commit is contained in:

committed by
Jonathan Rosser

parent
d719094a04
commit
2860f1bda5
@@ -23,8 +23,8 @@
|
|||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import openstackdocstheme
|
import openstackdocstheme
|
||||||
|
|
||||||
@@ -51,13 +51,17 @@ if current_series == "latest":
|
|||||||
suse_series = previous_series_name.capitalize()
|
suse_series = previous_series_name.capitalize()
|
||||||
else:
|
else:
|
||||||
series_names = current_series.capitalize()
|
series_names = current_series.capitalize()
|
||||||
latest_tag = subprocess.check_output(["git", "describe", "--abbrev=0", "--tag"]).strip().decode()
|
latest_tag = subprocess.check_output(["git", "describe", "--abbrev=0",
|
||||||
|
"--tag"]).strip().decode()
|
||||||
rdo_series = current_series_name
|
rdo_series = current_series_name
|
||||||
suse_series = current_series_name.capitalize()
|
suse_series = current_series_name.capitalize()
|
||||||
|
|
||||||
deploy_guide_prefix = "https://docs.openstack.org/project-deploy-guide/openstack-ansible/{}/%s".format(current_series)
|
deploy_guide_prefix = ("https://docs.openstack.org/project-deploy-guide/"
|
||||||
dev_docs_prefix = "https://docs.openstack.org/openstack-ansible/{}/%s".format(current_series)
|
"openstack-ansible/{}/%s".format(current_series))
|
||||||
role_docs_prefix = "https://docs.openstack.org/openstack-ansible-%s/{}".format(current_series)
|
dev_docs_prefix = ("https://docs.openstack.org/openstack-ansible/"
|
||||||
|
"{}/%s".format(current_series))
|
||||||
|
role_docs_prefix = ("https://docs.openstack.org/openstack-ansible-"
|
||||||
|
"%s/{}".format(current_series))
|
||||||
|
|
||||||
# Substitutions loader
|
# Substitutions loader
|
||||||
rst_epilog = """
|
rst_epilog = """
|
||||||
@@ -98,7 +102,7 @@ extensions = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
#templates_path = ['_templates']
|
# templates_path = ['_templates']
|
||||||
|
|
||||||
# The suffix of source filenames.
|
# The suffix of source filenames.
|
||||||
source_suffix = '.rst'
|
source_suffix = '.rst'
|
||||||
|
@@ -22,11 +22,9 @@
|
|||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import imp
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import openstackdocstheme
|
import openstackdocstheme
|
||||||
import yaml
|
import yaml
|
||||||
@@ -38,7 +36,7 @@ description = 'OpenStack-Ansible deploys OpenStack environments using Ansible.'
|
|||||||
previous_series_name = 'stein'
|
previous_series_name = 'stein'
|
||||||
current_series_name = 'train'
|
current_series_name = 'train'
|
||||||
|
|
||||||
## General information about the project.
|
# General information about the project.
|
||||||
author = 'OpenStack-Ansible Contributors'
|
author = 'OpenStack-Ansible Contributors'
|
||||||
category = 'Miscellaneous'
|
category = 'Miscellaneous'
|
||||||
copyright = '2014-2018, OpenStack-Ansible Contributors'
|
copyright = '2014-2018, OpenStack-Ansible Contributors'
|
||||||
@@ -51,10 +49,12 @@ current_series = openstackdocstheme.ext._get_series_name()
|
|||||||
if current_series == "latest":
|
if current_series == "latest":
|
||||||
latest_tag = "master"
|
latest_tag = "master"
|
||||||
branch = "master"
|
branch = "master"
|
||||||
upgrade_warning = "Upgrading to master is not recommended. Master is under heavy development, and is not stable."
|
upgrade_warning = ("Upgrading to master is not recommended. "
|
||||||
|
"Master is under heavy development, and is not stable.")
|
||||||
else:
|
else:
|
||||||
series_names = current_series.capitalize()
|
series_names = current_series.capitalize()
|
||||||
latest_tag = subprocess.check_output(["git", "describe", "--abbrev=0", "--tag"]).strip().decode()
|
latest_tag = subprocess.check_output(["git", "describe", "--abbrev=0",
|
||||||
|
"--tag"]).strip().decode()
|
||||||
branch = "stable/{}".format(current_series)
|
branch = "stable/{}".format(current_series)
|
||||||
upgrade_warning = "The upgrade is always under active development."
|
upgrade_warning = "The upgrade is always under active development."
|
||||||
|
|
||||||
@@ -65,8 +65,11 @@ with open(os.path.join(CONF_PATH, GNOCCHI_DETAILS), 'r') as fdesc:
|
|||||||
gnocchi_branch = gnocchi_file_content['gnocchi_git_track_branch']
|
gnocchi_branch = gnocchi_file_content['gnocchi_git_track_branch']
|
||||||
|
|
||||||
# References variable for substitutions
|
# References variable for substitutions
|
||||||
deploy_guide_prefix = "https://docs.openstack.org/project-deploy-guide/openstack-ansible/{}/%s".format(current_series)
|
deploy_guide_prefix = ("https://docs.openstack.org/"
|
||||||
dev_docs_prefix = "https://docs.openstack.org/openstack-ansible/{}/%s".format(current_series)
|
"project-deploy-guide/openstack-ansible/"
|
||||||
|
"{}/%s".format(current_series))
|
||||||
|
dev_docs_prefix = ("https://docs.openstack.org/openstack-ansible/"
|
||||||
|
"{}/%s".format(current_series))
|
||||||
|
|
||||||
# Substitutions loader
|
# Substitutions loader
|
||||||
rst_epilog = """
|
rst_epilog = """
|
||||||
@@ -77,7 +80,7 @@ rst_epilog = """
|
|||||||
.. |current_release_formal_name| replace:: {current_release_formal_name}
|
.. |current_release_formal_name| replace:: {current_release_formal_name}
|
||||||
.. |latest_tag| replace:: {latest_tag}
|
.. |latest_tag| replace:: {latest_tag}
|
||||||
.. |upgrade_warning| replace:: {upgrade_warning}
|
.. |upgrade_warning| replace:: {upgrade_warning}
|
||||||
""".format(
|
""".format( # noqa: E501
|
||||||
current_release_git_branch_name=branch,
|
current_release_git_branch_name=branch,
|
||||||
current_release_gnocchi_git_branch_name=gnocchi_branch,
|
current_release_gnocchi_git_branch_name=gnocchi_branch,
|
||||||
previous_series_name=previous_series_name,
|
previous_series_name=previous_series_name,
|
||||||
@@ -142,9 +145,7 @@ language = None
|
|||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
# List of patterns, relative to source directory, that match files and
|
||||||
# directories to ignore when looking for source files.
|
# directories to ignore when looking for source files.
|
||||||
exclude_patterns = [
|
exclude_patterns = ['admin/maintenance-tasks/galera.rst']
|
||||||
'admin/maintenance-tasks/galera.rst'
|
|
||||||
]
|
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all
|
# The reST default role (used for this markup: `text`) to use for all
|
||||||
# documents.
|
# documents.
|
||||||
|
@@ -234,7 +234,9 @@ def _load_from_json(filename, preferred_path=None, raise_if_missing=True):
|
|||||||
|
|
||||||
|
|
||||||
def load_inventory(preferred_path=None, default_inv=None, filename=None):
|
def load_inventory(preferred_path=None, default_inv=None, filename=None):
|
||||||
"""Create an inventory dictionary from the given source file or a default
|
"""Create an inventory dictionary.
|
||||||
|
|
||||||
|
Create inventory dictionary from the given source file or a default
|
||||||
inventory. If an inventory is found then a backup tarball is created
|
inventory. If an inventory is found then a backup tarball is created
|
||||||
as well.
|
as well.
|
||||||
|
|
||||||
@@ -327,8 +329,8 @@ def load_user_configuration(config_path=None):
|
|||||||
|
|
||||||
# Exit if no user_config was found and loaded
|
# Exit if no user_config was found and loaded
|
||||||
if not user_defined_config:
|
if not user_defined_config:
|
||||||
raise MissingDataSource(_get_search_paths(config_path) +
|
raise MissingDataSource(_get_search_paths(config_path)
|
||||||
_get_search_paths(config_path, 'conf.d'))
|
+ _get_search_paths(config_path, 'conf.d'))
|
||||||
|
|
||||||
logger.debug("User configuration loaded from: {}".format(user_config_file))
|
logger.debug("User configuration loaded from: {}".format(user_config_file))
|
||||||
return user_defined_config
|
return user_defined_config
|
||||||
|
@@ -53,13 +53,13 @@ source_suffix = '.rst'
|
|||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
author = u'OpenStack-Ansible Contributors'
|
author = 'OpenStack-Ansible Contributors'
|
||||||
category = u'Miscellaneous'
|
category = 'Miscellaneous'
|
||||||
copyright = u'2014-2016, OpenStack-Ansible Contributors'
|
copyright = '2014-2016, OpenStack-Ansible Contributors'
|
||||||
description = u'OpenStack-Ansible deploys OpenStack environments using Ansible.'
|
description = 'OpenStack-Ansible deploys OpenStack environments using Ansible.'
|
||||||
project = u'OpenStack-Ansible'
|
project = 'OpenStack-Ansible'
|
||||||
target_name = u'openstack-ansible'
|
target_name = 'openstack-ansible'
|
||||||
title = u'OpenStack-Ansible Release Notes'
|
title = 'OpenStack-Ansible Release Notes'
|
||||||
|
|
||||||
# The link to the browsable source code (for the left hand menu)
|
# The link to the browsable source code (for the left hand menu)
|
||||||
oslosphinx_cgit_link = (
|
oslosphinx_cgit_link = (
|
||||||
|
@@ -31,7 +31,8 @@ import yaml
|
|||||||
# we setup a representation for dict objects and register it
|
# we setup a representation for dict objects and register it
|
||||||
# with the yaml class.
|
# with the yaml class.
|
||||||
def represent_dict(self, data):
|
def represent_dict(self, data):
|
||||||
def key_function((key, value)):
|
def key_function(elem):
|
||||||
|
key = elem[0]
|
||||||
# Prioritizes certain keys when sorting.
|
# Prioritizes certain keys when sorting.
|
||||||
prio = {"model": 0, "pk": 1, "fields": 2}.get(key, 99)
|
prio = {"model": 0, "pk": 1, "fields": 2}.get(key, 99)
|
||||||
return (prio, key)
|
return (prio, key)
|
||||||
@@ -39,6 +40,7 @@ def represent_dict(self, data):
|
|||||||
items.sort(key=key_function)
|
items.sort(key=key_function)
|
||||||
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
|
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
|
||||||
|
|
||||||
|
|
||||||
yaml.add_representer(dict, represent_dict)
|
yaml.add_representer(dict, represent_dict)
|
||||||
|
|
||||||
|
|
||||||
@@ -100,5 +102,6 @@ def main():
|
|||||||
except yaml.YAMLError as exc:
|
except yaml.YAMLError as exc:
|
||||||
print(exc)
|
print(exc)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -40,7 +40,8 @@ import yaml
|
|||||||
# we setup a representation for dict objects and register it
|
# we setup a representation for dict objects and register it
|
||||||
# with the yaml class.
|
# with the yaml class.
|
||||||
def represent_dict(self, data):
|
def represent_dict(self, data):
|
||||||
def key_function((key, value)):
|
def key_function(elem):
|
||||||
|
key = elem[0]
|
||||||
# Prioritizes certain keys when sorting.
|
# Prioritizes certain keys when sorting.
|
||||||
prio = {"version": 0, "projects": 1, "repo": 2, "hash": 3}.get(key, 99)
|
prio = {"version": 0, "projects": 1, "repo": 2, "hash": 3}.get(key, 99)
|
||||||
return (prio, key)
|
return (prio, key)
|
||||||
@@ -48,6 +49,7 @@ def represent_dict(self, data):
|
|||||||
items.sort(key=key_function)
|
items.sort(key=key_function)
|
||||||
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
|
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
|
||||||
|
|
||||||
|
|
||||||
yaml.add_representer(dict, represent_dict)
|
yaml.add_representer(dict, represent_dict)
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ yaml.add_representer(dict, represent_dict)
|
|||||||
def yaml_dump(dump, indentSize=2):
|
def yaml_dump(dump, indentSize=2):
|
||||||
stream = StringIO(dump)
|
stream = StringIO(dump)
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
pat = re.compile('(\s*)([^:]*)(:*)')
|
pat = re.compile(r'(\s*)([^:]*)(:*)')
|
||||||
last = None
|
last = None
|
||||||
|
|
||||||
prefix = 0
|
prefix = 0
|
||||||
@@ -134,5 +136,6 @@ def main():
|
|||||||
# Print the output, formatted as expected
|
# Print the output, formatted as expected
|
||||||
print(yaml_dump(output))
|
print(yaml_dump(output))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
|
|
||||||
# Keep hacking first, it pulls in the right versions of flake8, mccabe and pyflakes
|
# Keep hacking first, it pulls in the right versions of flake8, mccabe and pyflakes
|
||||||
hacking>=1.1.0,<1.2.0 # Apache-2.0
|
hacking>=3.0,<3.1.0 # Apache-2.0
|
||||||
bashate>=0.5.1 # Apache-2.0
|
bashate>=0.5.1 # Apache-2.0
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
mock>=2.0.0 # BSD
|
mock>=2.0.0 # BSD
|
||||||
|
@@ -29,11 +29,11 @@ INV_DIR = 'inventory'
|
|||||||
|
|
||||||
sys.path.append(path.join(os.getcwd(), INV_DIR))
|
sys.path.append(path.join(os.getcwd(), INV_DIR))
|
||||||
|
|
||||||
from osa_toolkit import dictutils
|
import dynamic_inventory # noqa: E402
|
||||||
import dynamic_inventory
|
from osa_toolkit import dictutils # noqa: E402
|
||||||
from osa_toolkit import filesystem as fs
|
from osa_toolkit import filesystem as fs # noqa: E402
|
||||||
from osa_toolkit import generate as di
|
from osa_toolkit import generate as di # noqa: E402
|
||||||
from osa_toolkit import tools
|
from osa_toolkit import tools # noqa: E402
|
||||||
|
|
||||||
TARGET_DIR = path.join(os.getcwd(), 'tests', 'inventory')
|
TARGET_DIR = path.join(os.getcwd(), 'tests', 'inventory')
|
||||||
BASE_ENV_DIR = INV_DIR
|
BASE_ENV_DIR = INV_DIR
|
||||||
@@ -1106,7 +1106,6 @@ class TestOverridingEnvVars(OverridingEnvBase):
|
|||||||
# a partial override file
|
# a partial override file
|
||||||
|
|
||||||
vol = self.cinder_config['container_skel']['cinder_volumes_container']
|
vol = self.cinder_config['container_skel']['cinder_volumes_container']
|
||||||
keys = vol.keys()
|
|
||||||
to_delete = []
|
to_delete = []
|
||||||
for key in vol.keys():
|
for key in vol.keys():
|
||||||
if not key == 'properties':
|
if not key == 'properties':
|
||||||
@@ -1445,7 +1444,8 @@ class TestInventoryGroupConstraints(unittest.TestCase):
|
|||||||
# This should only work on groups, but stuff like '_meta' and 'all'
|
# This should only work on groups, but stuff like '_meta' and 'all'
|
||||||
# are in here, too.
|
# are in here, too.
|
||||||
for key, values in inventory.items():
|
for key, values in inventory.items():
|
||||||
# The keys for children/hosts can exist, the important part is being empty lists.
|
# The keys for children/hosts can exist, the important part is
|
||||||
|
# being empty lists.
|
||||||
has_children = bool(inventory.get('children'))
|
has_children = bool(inventory.get('children'))
|
||||||
has_hosts = bool(inventory.get('hosts'))
|
has_hosts = bool(inventory.get('hosts'))
|
||||||
|
|
||||||
@@ -1482,7 +1482,6 @@ class TestInventoryGroupConstraints(unittest.TestCase):
|
|||||||
"""Integration test making sure the whole script fails."""
|
"""Integration test making sure the whole script fails."""
|
||||||
env = self._create_bad_env(self.env)
|
env = self._create_bad_env(self.env)
|
||||||
|
|
||||||
|
|
||||||
config = get_config()
|
config = get_config()
|
||||||
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
@@ -1494,7 +1493,7 @@ class TestInventoryGroupConstraints(unittest.TestCase):
|
|||||||
mocks['load_environment'].return_value = env
|
mocks['load_environment'].return_value = env
|
||||||
mocks['load_user_configuration'].return_value = config
|
mocks['load_user_configuration'].return_value = config
|
||||||
|
|
||||||
with self.assertRaises(di.GroupConflict) as context:
|
with self.assertRaises(di.GroupConflict):
|
||||||
get_inventory()
|
get_inventory()
|
||||||
|
|
||||||
def test_group_validation_unit(self):
|
def test_group_validation_unit(self):
|
||||||
@@ -1516,6 +1515,7 @@ class TestInventoryGroupConstraints(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(result)
|
self.assertTrue(result)
|
||||||
|
|
||||||
|
|
||||||
class TestL3ProviderNetworkConfig(TestConfigCheckBase):
|
class TestL3ProviderNetworkConfig(TestConfigCheckBase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestL3ProviderNetworkConfig, self).setUp()
|
super(TestL3ProviderNetworkConfig, self).setUp()
|
||||||
@@ -1544,5 +1544,6 @@ class TestL3ProviderNetworkConfig(TestConfigCheckBase):
|
|||||||
aio1_container_networks = aio1_host_vars['container_networks']
|
aio1_container_networks = aio1_host_vars['container_networks']
|
||||||
self.assertNotIn('management_address', aio1_container_networks)
|
self.assertNotIn('management_address', aio1_container_networks)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(catchbreak=True)
|
unittest.main(catchbreak=True)
|
||||||
|
4
tox.ini
4
tox.ini
@@ -77,7 +77,9 @@ commands =
|
|||||||
# Ignores the following rules due to how ansible modules work in general
|
# Ignores the following rules due to how ansible modules work in general
|
||||||
# F403 'from ansible.module_utils.basic import *' used;
|
# F403 'from ansible.module_utils.basic import *' used;
|
||||||
# unable to detect undefined names
|
# unable to detect undefined names
|
||||||
ignore=F403
|
# E124 closing bracket does not match visual indentation
|
||||||
|
# W503 line break before binary operator
|
||||||
|
ignore=F403,E124,W503
|
||||||
|
|
||||||
[testenv:bashate]
|
[testenv:bashate]
|
||||||
commands =
|
commands =
|
||||||
|
Reference in New Issue
Block a user