diff --git a/actions/actions.py b/actions/actions.py index 083d262a..15147b76 100755 --- a/actions/actions.py +++ b/actions/actions.py @@ -26,6 +26,7 @@ def _add_path(path): if path not in sys.path: sys.path.insert(1, path) + _add_path(_hooks) _add_path(_root) diff --git a/actions/openstack_upgrade.py b/actions/openstack_upgrade.py index aca6b699..103324b4 100755 --- a/actions/openstack_upgrade.py +++ b/actions/openstack_upgrade.py @@ -26,6 +26,7 @@ def _add_path(path): if path not in sys.path: sys.path.insert(1, path) + _add_path(_hooks) _add_path(_root) @@ -56,5 +57,6 @@ def openstack_upgrade(): os.execl('./hooks/config-changed-postupgrade', 'config-changed-postupgrade') + if __name__ == '__main__': openstack_upgrade() diff --git a/actions/security_checklist.py b/actions/security_checklist.py index d7a6c27f..3bfd9c43 100755 --- a/actions/security_checklist.py +++ b/actions/security_checklist.py @@ -175,5 +175,6 @@ def main(): [config['config_path'], config['config_file']]) return audits.action_parse_results(audits.run(config)) + if __name__ == "__main__": sys.exit(main()) diff --git a/hooks/keystone_utils.py b/hooks/keystone_utils.py index c790c1b0..7b0d1488 100644 --- a/hooks/keystone_utils.py +++ b/hooks/keystone_utils.py @@ -881,7 +881,7 @@ def get_admin_token(): if l.split(' ')[0] == 'admin_token': try: return l.split('=')[1].strip() - except: + except Exception: error_out('Could not parse admin_token line from %s' % KEYSTONE_CONF) error_out('Could not find admin_token line in %s' % KEYSTONE_CONF) @@ -2195,7 +2195,7 @@ def check_extra_for_assess_status(configs): if relation_ids('ha'): try: get_hacluster_config() - except: + except Exception: return ('blocked', 'hacluster missing configuration: ' 'vip, vip_iface, vip_cidr') diff --git a/test-requirements.txt b/test-requirements.txt index 7d9c2587..44b50231 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,7 +10,7 @@ charm-tools>=2.4.4 requests>=2.18.4 mock>=1.2 -flake8>=2.2.4,<=2.4.1 +flake8>=2.2.4 stestr>=2.2.0 coverage>=4.5.2 pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking) diff --git a/tox.ini b/tox.ini index 20dbbfc5..355780fa 100644 --- a/tox.ini +++ b/tox.ini @@ -111,5 +111,5 @@ commands = functest-run-suite --keep-model --bundle {posargs} [flake8] -ignore = E402,E226 +ignore = E402,E226,W504 exclude = */charmhelpers diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index c7dc9d98..ca8730f6 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -27,6 +27,7 @@ def _add_path(path): if path not in sys.path: sys.path.insert(1, path) + _add_path(_actions) _add_path(_hooks) _add_path(_charmhelpers) diff --git a/unit_tests/test_actions.py b/unit_tests/test_actions.py index 61e9ce77..40933538 100644 --- a/unit_tests/test_actions.py +++ b/unit_tests/test_actions.py @@ -20,9 +20,9 @@ from test_utils import CharmTestCase with patch('charmhelpers.contrib.openstack.utils.' 'snap_install_requested') as snap_install_requested, \ patch('keystone_utils.register_configs') as configs: - snap_install_requested.return_value = False - configs.return_value = 'test-config' - import actions.actions + snap_install_requested.return_value = False + configs.return_value = 'test-config' + import actions.actions class PauseTestCase(CharmTestCase):