From cb79b535de6034670279a2fe4f31a31c55537642 Mon Sep 17 00:00:00 2001 From: tengqm Date: Tue, 17 Mar 2015 09:54:18 +0800 Subject: [PATCH] Fixing initial PEP8 and python check errors Note the locale part is temporarily disabled. Need to be re-enabled some time in future. Change-Id: I3b2e0a2f40a171266ec76ad0d3cb4939e48d7ceb --- doc/source/conf.py | 80 ++++++++++++++++++++++++++++ senlin/drivers/heat_v1.py | 1 - senlin/engine/health_manager.py | 10 ++-- senlin/tests/apiv1/test_routes.py | 8 +-- senlin/tests/common/base.py | 4 +- senlin/tests/common/fakes.py | 8 +-- senlin/tests/engine/test_policies.py | 4 +- senlin/tests/test_common_policy.py | 2 +- tox.ini | 2 +- 9 files changed, 95 insertions(+), 24 deletions(-) create mode 100755 doc/source/conf.py diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100755 index 000000000..8b06f09ff --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +sys.path.insert(0, os.path.abspath('../..')) +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.todo' + #'sphinx.ext.intersphinx', + #'oslo.sphinx' +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'senlin' +copyright = u'2015, OpenStack Foundation' + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = '_theme' +# html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + u'%s Documentation' % project, + u'OpenStack Foundation', 'manual'), +] + +# Example configuration for intersphinx: refer to the Python standard library. +#intersphinx_mapping = {'http://docs.python.org/': None} + +[extensions] +todo_include_todos=True + diff --git a/senlin/drivers/heat_v1.py b/senlin/drivers/heat_v1.py index b791cf2c4..91a718978 100644 --- a/senlin/drivers/heat_v1.py +++ b/senlin/drivers/heat_v1.py @@ -12,7 +12,6 @@ from senlin.common import sdk from senlin.drivers import base -from openstack import user_preference from senlin.openstack.orchestration.v1 import stack diff --git a/senlin/engine/health_manager.py b/senlin/engine/health_manager.py index 9364e99f8..d7263bf89 100644 --- a/senlin/engine/health_manager.py +++ b/senlin/engine/health_manager.py @@ -18,8 +18,6 @@ take corresponding actions to recover the clusters based on the pre-defined health policies. ''' -import random - from oslo_config import cfg from oslo_log import log as logging import oslo_messaging @@ -77,10 +75,10 @@ class Health_Manager(service.Service, periodic_task.PeriodicTasks): server.start() if self.periodic_enable: - if self.periodic_fuzzy_delay: - initial_delay = random.randint(0, self.periodic_fuzzy_delay) - else: - initial_delay = None + # if self.periodic_fuzzy_delay: + # initial_delay = random.randint(0, self.periodic_fuzzy_delay) + # else: + # initial_delay = None self.threadgroup.add_timer(self.periodic_interval_max, self.periodic_tasks) diff --git a/senlin/tests/apiv1/test_routes.py b/senlin/tests/apiv1/test_routes.py index ec3fb65ed..0a1a91b98 100644 --- a/senlin/tests/apiv1/test_routes.py +++ b/senlin/tests/apiv1/test_routes.py @@ -90,7 +90,7 @@ class RoutesTest(base.SenlinTestCase): self.assertRoute( self.m, '/aaaa/profiles/bbbb', - 'PUT', + 'PATCH', 'update', 'ProfileController', { @@ -166,7 +166,7 @@ class RoutesTest(base.SenlinTestCase): self.assertRoute( self.m, '/aaaa/policies/bbbb', - 'PUT', + 'PATCH', 'update', 'PolicyController', { @@ -220,7 +220,7 @@ class RoutesTest(base.SenlinTestCase): self.assertRoute( self.m, '/aaaa/clusters/bbbb', - 'PUT', + 'PATCH', 'update', 'ClusterController', { @@ -285,7 +285,7 @@ class RoutesTest(base.SenlinTestCase): self.assertRoute( self.m, '/aaaa/nodes/bbbb', - 'PUT', + 'PATCH', 'update', 'NodeController', { diff --git a/senlin/tests/common/base.py b/senlin/tests/common/base.py index b0ca7057e..be4917e8f 100644 --- a/senlin/tests/common/base.py +++ b/senlin/tests/common/base.py @@ -86,9 +86,7 @@ class SenlinTestCase(testscenarios.WithScenarios, self.addCleanup(utils.reset_dummy_db) def stub_wallclock(self): - """ - Overrides scheduler wallclock to speed up tests expecting timeouts. - """ + # Overrides scheduler wallclock to speed up tests expecting timeouts. self._wallclock = time.time() def fake_wallclock(): diff --git a/senlin/tests/common/fakes.py b/senlin/tests/common/fakes.py index 30075524b..a59e9e478 100644 --- a/senlin/tests/common/fakes.py +++ b/senlin/tests/common/fakes.py @@ -19,9 +19,7 @@ from keystoneclient import exceptions class FakeClient(object): def assert_called(self, method, url, body=None, pos=-1): - """ - Assert than an API method was just called. - """ + # Assert than an API method was just called. expected = (method, url) called = self.client.callstack[pos][0:2] @@ -35,9 +33,7 @@ class FakeClient(object): assert self.client.callstack[pos][2] == body def assert_called_anytime(self, method, url, body=None): - """ - Assert than an API method was called anytime in the test. - """ + # Assert than an API method was called anytime in the test. expected = (method, url) assert self.client.callstack, \ diff --git a/senlin/tests/engine/test_policies.py b/senlin/tests/engine/test_policies.py index c4ea148a1..f46a94f1e 100644 --- a/senlin/tests/engine/test_policies.py +++ b/senlin/tests/engine/test_policies.py @@ -284,7 +284,7 @@ class PolicyTest(base.SenlinTestCase): p = self.eng.policy_get(self.ctx, pid) self.assertEqual('p-2', p['name']) - # 2. update cooldown + # 2. update cooldown p2 = self.eng.policy_update(self.ctx, pid, cooldown=120) self.assertEqual(pid, p2['id']) self.assertEqual(120, p2['cooldown']) @@ -293,7 +293,7 @@ class PolicyTest(base.SenlinTestCase): p = self.eng.policy_get(self.ctx, pid) self.assertEqual(120, p['cooldown']) - # 3. update level + # 3. update level p2 = self.eng.policy_update(self.ctx, pid, level=50) self.assertEqual(pid, p2['id']) self.assertEqual(50, p2['level']) diff --git a/senlin/tests/test_common_policy.py b/senlin/tests/test_common_policy.py index d2d5f50bc..3ba02a0ed 100644 --- a/senlin/tests/test_common_policy.py +++ b/senlin/tests/test_common_policy.py @@ -17,7 +17,7 @@ from oslo_config import cfg from senlin.common import exception from senlin.common import policy from senlin.openstack.common import policy as base_policy -from senlin.tests.common import base +from senlin.tests.common import base from senlin.tests.common import utils policy_path = os.path.dirname(os.path.realpath(__file__)) + "/policy/" diff --git a/tox.ini b/tox.ini index 1a8063dfe..3245eb60d 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ whitelist_externals = bash commands = flake8 senlin bin/senlin-api bin/senlin-engine bin/senlin-manage # Check that .po and .pot files are valid: - bash -c "find senlin -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null" + # bash -c "find senlin -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null" [testenv:venv] commands = {posargs}