From 017d25f49e60e18365a50756f524e15f8d4fa78a Mon Sep 17 00:00:00 2001 From: Ekaterina Chernova Date: Wed, 4 Feb 2015 17:57:00 +0300 Subject: [PATCH] Resolve and enable E265 pep8 issue E265 block comment should start with '# ' Change-Id: I1a8b971776deb8b05b84be169571b9f1e573d2ba --- murano/api/v1/environments.py | 4 ++-- murano/common/server.py | 8 ++++---- murano/common/wsgi.py | 6 +++--- murano/db/catalog/api.py | 2 +- .../versions/001_inital_version.py | 4 ++-- .../versions/002_add_package_supplier_info.py | 4 ++-- .../versions/003_add_action_entry.py | 2 +- .../versions/004_change_package_desc_type.py | 4 ++-- murano/db/models.py | 4 ++-- murano/db/services/environments.py | 6 +++--- murano/db/services/sessions.py | 16 +++++++--------- murano/dsl/results_serializer.py | 2 +- murano/tests/unit/api/base.py | 2 +- murano/tests/unit/utils.py | 2 +- tox.ini | 3 +-- 15 files changed, 33 insertions(+), 36 deletions(-) diff --git a/murano/api/v1/environments.py b/murano/api/v1/environments.py index 7679fcb13..8044336ec 100644 --- a/murano/api/v1/environments.py +++ b/murano/api/v1/environments.py @@ -44,7 +44,7 @@ class Controller(object): LOG.debug('Environments:List') policy.check('list_environments', request.context) - #Only environments from same tenant as user should be returned + # Only environments from same tenant as user should be returned filters = {'tenant_id': request.context.tenant} environments = envs.EnvironmentServices.get_environments_by(filters) environments = [env.to_dict() for env in environments] @@ -99,7 +99,7 @@ class Controller(object): if hasattr(request, 'context') and request.context.session: session_id = request.context.session - #add services to env + # add services to env get_data = core_services.CoreServices.get_data env['services'] = get_data(environment_id, '/services', session_id) diff --git a/murano/common/server.py b/murano/common/server.py index 21540d31f..6dc077e89 100644 --- a/murano/common/server.py +++ b/murano/common/server.py @@ -70,7 +70,7 @@ class ResultEndpoint(object): environment.version += 1 environment.save(unit) - #close deployment + # close deployment deployment = get_last_deployment(unit, environment.id) deployment.finished = timeutils.utcnow() @@ -93,7 +93,7 @@ class ResultEndpoint(object): deployment.statuses.append(status) deployment.save(unit) - #close session + # close session conf_session = unit.query(models.Session).filter_by( **{'environment_id': environment.id, 'state': states.SessionState.DEPLOYING if not deleted @@ -106,7 +106,7 @@ class ResultEndpoint(object): conf_session.state = states.SessionState.DEPLOYED conf_session.save(unit) - #output application tracking information + # output application tracking information message = ''.format( environment.id, environment.tenant_id, @@ -174,7 +174,7 @@ def report_notification(report): status.update(report) unit = session.get_session() - #connect with deployment + # connect with deployment with unit.begin(): running_deployment = get_last_deployment(unit, status.environment_id) diff --git a/murano/common/wsgi.py b/murano/common/wsgi.py index 40a136ad4..1c5943efe 100644 --- a/murano/common/wsgi.py +++ b/murano/common/wsgi.py @@ -472,7 +472,7 @@ class XMLDictSerializer(DictSerializer): self._add_xmlns(node, has_atom) return node.toprettyxml(indent=' ', encoding='UTF-8') - #NOTE (ameade): the has_atom should be removed after all of the + # NOTE (ameade): the has_atom should be removed after all of the # xml serializers and view builders have been updated to the current # spec that required all responses include the xmlns:atom, the has_atom # flag is to prevent current tests from breaking @@ -492,7 +492,7 @@ class XMLDictSerializer(DictSerializer): if xmlns: result.setAttribute('xmlns', xmlns) - #TODO(bcwaldon): accomplish this without a type-check + # TODO(bcwaldon): accomplish this without a type-check if type(data) is list: collections = metadata.get('list_collections', {}) if nodename in collections: @@ -511,7 +511,7 @@ class XMLDictSerializer(DictSerializer): for item in data: node = self._to_xml_node(doc, metadata, singular, item) result.appendChild(node) - #TODO(bcwaldon): accomplish this without a type-check + # TODO(bcwaldon): accomplish this without a type-check elif type(data) is dict: collections = metadata.get('dict_collections', {}) if nodename in collections: diff --git a/murano/db/catalog/api.py b/murano/db/catalog/api.py index 40d9fbac5..1a23b76f6 100644 --- a/murano/db/catalog/api.py +++ b/murano/db/catalog/api.py @@ -249,7 +249,7 @@ def package_search(filters, context, limit=None): if context.is_admin: if not include_disabled: - #NOTE(efedorova): is needed for SA 0.7.9, but could be done + # NOTE(efedorova): is needed for SA 0.7.9, but could be done # simpler in SA 0.8. See http://goo.gl/9stlKu for a details query = session.query(pkg).filter(pkg.__table__.c.enabled) else: diff --git a/murano/db/migration/alembic_migrations/versions/001_inital_version.py b/murano/db/migration/alembic_migrations/versions/001_inital_version.py index 274a78455..33d3dea9e 100644 --- a/murano/db/migration/alembic_migrations/versions/001_inital_version.py +++ b/murano/db/migration/alembic_migrations/versions/001_inital_version.py @@ -253,7 +253,7 @@ def upgrade(): ) _create_default_categories(op) - ### end Alembic commands ### + # end Alembic commands # def downgrade(): @@ -273,4 +273,4 @@ def downgrade(): op.drop_table('category') op.drop_table('tag') op.drop_table('environment') - ### end Alembic commands ### + # end Alembic commands # diff --git a/murano/db/migration/alembic_migrations/versions/002_add_package_supplier_info.py b/murano/db/migration/alembic_migrations/versions/002_add_package_supplier_info.py index 42b19b0b4..a8811d23d 100644 --- a/murano/db/migration/alembic_migrations/versions/002_add_package_supplier_info.py +++ b/murano/db/migration/alembic_migrations/versions/002_add_package_supplier_info.py @@ -40,10 +40,10 @@ def upgrade(): 'package', sa.Column('supplier', sa.types.Text()) ) - ### end Alembic commands ### + # end Alembic commands # def downgrade(): op.drop_column('package', 'supplier') op.drop_column('package', 'supplier_logo') - ### end Alembic commands ### + # end Alembic commands # diff --git a/murano/db/migration/alembic_migrations/versions/003_add_action_entry.py b/murano/db/migration/alembic_migrations/versions/003_add_action_entry.py index ac2f88b43..98c1c7443 100644 --- a/murano/db/migration/alembic_migrations/versions/003_add_action_entry.py +++ b/murano/db/migration/alembic_migrations/versions/003_add_action_entry.py @@ -89,4 +89,4 @@ def downgrade(): ) op.drop_table('task') - ### end Alembic commands ### + # end Alembic commands # diff --git a/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py b/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py index 8e5f49e7f..9b47bec3f 100644 --- a/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py +++ b/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py @@ -98,7 +98,7 @@ def upgrade(): 'class_definition', 'package', ['package_id'], ['id']) - ### end Alembic commands ### + # end Alembic commands # def downgrade(): @@ -166,4 +166,4 @@ def downgrade(): 'class_definition', 'package', ['package_id'], ['id']) - ### end Alembic commands ### + # end Alembic commands # diff --git a/murano/db/models.py b/murano/db/models.py index f117e2610..ce0c118a1 100644 --- a/murano/db/models.py +++ b/murano/db/models.py @@ -94,7 +94,7 @@ class Session(Base, TimestampMixin): def to_dict(self): dictionary = super(Session, self).to_dict() del dictionary['description'] - #object relations may be not loaded yet + # object relations may be not loaded yet if 'environment' in dictionary: del dictionary['environment'] return dictionary @@ -138,7 +138,7 @@ class Status(Base, TimestampMixin): def to_dict(self): dictionary = super(Status, self).to_dict() - #object relations may be not loaded yet + # object relations may be not loaded yet if 'deployment' in dictionary: del dictionary['deployment'] return dictionary diff --git a/murano/db/services/environments.py b/murano/db/services/environments.py index 4eff4ee4a..09b2019c0 100644 --- a/murano/db/services/environments.py +++ b/murano/db/services/environments.py @@ -56,7 +56,7 @@ class EnvironmentServices(object): :param environment_id: Id of environment for which we checking status. :return: Environment status """ - #Deploying: there is at least one valid session with status `deploying` + # Deploying: there is at least one valid session with status deploying session_list = sessions.SessionServices.get_sessions(environment_id) has_opened = False for session in session_list: @@ -77,7 +77,7 @@ class EnvironmentServices(object): @staticmethod def create(environment_params, tenant_id): - #tagging environment by tenant_id for later checks + # tagging environment by tenant_id for later checks """Creates environment with specified params, in particular - name :param environment_params: Dict, e.g. {'name': 'env-name'} @@ -106,7 +106,7 @@ class EnvironmentServices(object): with unit.begin(): unit.add(environment) - #saving environment as Json to itself + # saving environment as Json to itself environment.update({'description': data}) environment.save(unit) diff --git a/murano/db/services/sessions.py b/murano/db/services/sessions.py index 1db5f4116..ce2c2b1e3 100644 --- a/murano/db/services/sessions.py +++ b/murano/db/services/sessions.py @@ -33,13 +33,13 @@ class SessionServices(object): # Here we duplicate logic for reducing calls to database # Checks for validation is same as in validate. query = unit.query(models.Session).filter( - #Get all session for this environment + # Get all session for this environment models.Session.environment_id == environment_id, - #Only sessions with same version as current env version are valid + # Only sessions with same version as current env version are valid ) if state: - #in this state, if state is not specified return in all states + # in this state, if state is not specified return in all states query = query.filter(models.Session.state == state), return query.order_by(models.Session.version.desc(), @@ -79,17 +79,17 @@ class SessionServices(object): :param session: Session for validation """ - #if other session is deploying now current session is invalid + # if other session is deploying now current session is invalid unit = db_session.get_session() - #if environment version is higher then version on which current session - #is created then other session was already deployed + # if environment version is higher then version on which current + # session is created then other session was already deployed current_env = unit.query(models.Environment).\ get(session.environment_id) if current_env.version > session.version: return False - #if other session is deploying now current session is invalid + # if other session is deploying now current session is invalid other_is_deploying = unit.query(models.Session).filter_by( environment_id=session.environment_id, state=states.SessionState.DEPLOYING @@ -109,8 +109,6 @@ class SessionServices(object): :param token: auth token that is going to be used by orchestration """ - #Set X-Auth-Token for conductor - deleted = session.description['Objects'] is None action_name = None if deleted else 'deploy' actions.ActionServices.submit_task( diff --git a/murano/dsl/results_serializer.py b/murano/dsl/results_serializer.py index 3ac59d96e..68d3db2a2 100644 --- a/murano/dsl/results_serializer.py +++ b/murano/dsl/results_serializer.py @@ -96,7 +96,7 @@ def _pass1_serialize(value, parent, serialized_objects, result = value.to_dictionary() if designer_attributes_getter is not None: result['?'].update(designer_attributes_getter(value.object_id)) - #deserialize and merge list of actions + # deserialize and merge list of actions actions = _serialize_available_action(value) result['?']['_actions'] = _merge_actions( result['?'].get('_actions', {}), actions) diff --git a/murano/tests/unit/api/base.py b/murano/tests/unit/api/base.py index 1987ce5dc..69e648dfa 100644 --- a/murano/tests/unit/api/base.py +++ b/murano/tests/unit/api/base.py @@ -103,7 +103,7 @@ class ControllerTest(object): def __init__(self, *args, **kwargs): super(ControllerTest, self).__init__(*args, **kwargs) - #cfg.CONF.set_default('host', 'server.test') + # cfg.CONF.set_default('host', 'server.test') self.api_version = '1.0' self.tenant = 'test_tenant' self.mock_policy_check = None diff --git a/murano/tests/unit/utils.py b/murano/tests/unit/utils.py index e0dc39c61..1a2c27974 100644 --- a/murano/tests/unit/utils.py +++ b/murano/tests/unit/utils.py @@ -23,7 +23,7 @@ def dummy_context(user='test_username', tenant_id='test_tenant_id', return context.RequestContext.from_dict({ 'tenant': tenant_id, 'user': user, - #'roles': roles, # Commented until policy check changes land + # 'roles': roles, # Commented until policy check changes land 'is_admin': is_admin, }) diff --git a/tox.ini b/tox.ini index 9f997bbd8..a12f67558 100644 --- a/tox.ini +++ b/tox.ini @@ -39,13 +39,12 @@ commands = oslo-config-generator --config-file etc/oslo-config-generator/murano. [flake8] # H233 Python 3.x incompatible use of print operator -# E265 block comment should start with '# ' # H307 like imports should be grouped together # H405 Multi line docstring summary not separated with an empty line # H702 Argument to _ must be just a string # H904 Wrap long lines in parentheses instead of a backslash -ignore = H233,H307,E265,H405,H702,H904 +ignore = H233,H307,H405,H702,H904 show-source = true builtins = _ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools