Resolve and enable E265 pep8 issue

E265 block comment should start with '# '

Change-Id: I1a8b971776deb8b05b84be169571b9f1e573d2ba
This commit is contained in:
Ekaterina Chernova 2015-02-04 17:57:00 +03:00
parent 87a63bf24e
commit 017d25f49e
15 changed files with 33 additions and 36 deletions

View File

@ -44,7 +44,7 @@ class Controller(object):
LOG.debug('Environments:List') LOG.debug('Environments:List')
policy.check('list_environments', request.context) 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} filters = {'tenant_id': request.context.tenant}
environments = envs.EnvironmentServices.get_environments_by(filters) environments = envs.EnvironmentServices.get_environments_by(filters)
environments = [env.to_dict() for env in environments] environments = [env.to_dict() for env in environments]
@ -99,7 +99,7 @@ class Controller(object):
if hasattr(request, 'context') and request.context.session: if hasattr(request, 'context') and request.context.session:
session_id = request.context.session session_id = request.context.session
#add services to env # add services to env
get_data = core_services.CoreServices.get_data get_data = core_services.CoreServices.get_data
env['services'] = get_data(environment_id, '/services', session_id) env['services'] = get_data(environment_id, '/services', session_id)

View File

@ -70,7 +70,7 @@ class ResultEndpoint(object):
environment.version += 1 environment.version += 1
environment.save(unit) environment.save(unit)
#close deployment # close deployment
deployment = get_last_deployment(unit, environment.id) deployment = get_last_deployment(unit, environment.id)
deployment.finished = timeutils.utcnow() deployment.finished = timeutils.utcnow()
@ -93,7 +93,7 @@ class ResultEndpoint(object):
deployment.statuses.append(status) deployment.statuses.append(status)
deployment.save(unit) deployment.save(unit)
#close session # close session
conf_session = unit.query(models.Session).filter_by( conf_session = unit.query(models.Session).filter_by(
**{'environment_id': environment.id, **{'environment_id': environment.id,
'state': states.SessionState.DEPLOYING if not deleted 'state': states.SessionState.DEPLOYING if not deleted
@ -106,7 +106,7 @@ class ResultEndpoint(object):
conf_session.state = states.SessionState.DEPLOYED conf_session.state = states.SessionState.DEPLOYED
conf_session.save(unit) conf_session.save(unit)
#output application tracking information # output application tracking information
message = '<EnvId: {0} TenantId: {1} Status: {2} Apps: {3}>'.format( message = '<EnvId: {0} TenantId: {1} Status: {2} Apps: {3}>'.format(
environment.id, environment.id,
environment.tenant_id, environment.tenant_id,
@ -174,7 +174,7 @@ def report_notification(report):
status.update(report) status.update(report)
unit = session.get_session() unit = session.get_session()
#connect with deployment # connect with deployment
with unit.begin(): with unit.begin():
running_deployment = get_last_deployment(unit, running_deployment = get_last_deployment(unit,
status.environment_id) status.environment_id)

View File

@ -472,7 +472,7 @@ class XMLDictSerializer(DictSerializer):
self._add_xmlns(node, has_atom) self._add_xmlns(node, has_atom)
return node.toprettyxml(indent=' ', encoding='UTF-8') 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 # xml serializers and view builders have been updated to the current
# spec that required all responses include the xmlns:atom, the has_atom # spec that required all responses include the xmlns:atom, the has_atom
# flag is to prevent current tests from breaking # flag is to prevent current tests from breaking
@ -492,7 +492,7 @@ class XMLDictSerializer(DictSerializer):
if xmlns: if xmlns:
result.setAttribute('xmlns', 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: if type(data) is list:
collections = metadata.get('list_collections', {}) collections = metadata.get('list_collections', {})
if nodename in collections: if nodename in collections:
@ -511,7 +511,7 @@ class XMLDictSerializer(DictSerializer):
for item in data: for item in data:
node = self._to_xml_node(doc, metadata, singular, item) node = self._to_xml_node(doc, metadata, singular, item)
result.appendChild(node) result.appendChild(node)
#TODO(bcwaldon): accomplish this without a type-check # TODO(bcwaldon): accomplish this without a type-check
elif type(data) is dict: elif type(data) is dict:
collections = metadata.get('dict_collections', {}) collections = metadata.get('dict_collections', {})
if nodename in collections: if nodename in collections:

View File

@ -249,7 +249,7 @@ def package_search(filters, context, limit=None):
if context.is_admin: if context.is_admin:
if not include_disabled: 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 # simpler in SA 0.8. See http://goo.gl/9stlKu for a details
query = session.query(pkg).filter(pkg.__table__.c.enabled) query = session.query(pkg).filter(pkg.__table__.c.enabled)
else: else:

View File

@ -253,7 +253,7 @@ def upgrade():
) )
_create_default_categories(op) _create_default_categories(op)
### end Alembic commands ### # end Alembic commands #
def downgrade(): def downgrade():
@ -273,4 +273,4 @@ def downgrade():
op.drop_table('category') op.drop_table('category')
op.drop_table('tag') op.drop_table('tag')
op.drop_table('environment') op.drop_table('environment')
### end Alembic commands ### # end Alembic commands #

View File

@ -40,10 +40,10 @@ def upgrade():
'package', 'package',
sa.Column('supplier', sa.types.Text()) sa.Column('supplier', sa.types.Text())
) )
### end Alembic commands ### # end Alembic commands #
def downgrade(): def downgrade():
op.drop_column('package', 'supplier') op.drop_column('package', 'supplier')
op.drop_column('package', 'supplier_logo') op.drop_column('package', 'supplier_logo')
### end Alembic commands ### # end Alembic commands #

View File

@ -89,4 +89,4 @@ def downgrade():
) )
op.drop_table('task') op.drop_table('task')
### end Alembic commands ### # end Alembic commands #

View File

@ -98,7 +98,7 @@ def upgrade():
'class_definition', 'package', 'class_definition', 'package',
['package_id'], ['id']) ['package_id'], ['id'])
### end Alembic commands ### # end Alembic commands #
def downgrade(): def downgrade():
@ -166,4 +166,4 @@ def downgrade():
'class_definition', 'package', 'class_definition', 'package',
['package_id'], ['id']) ['package_id'], ['id'])
### end Alembic commands ### # end Alembic commands #

View File

@ -94,7 +94,7 @@ class Session(Base, TimestampMixin):
def to_dict(self): def to_dict(self):
dictionary = super(Session, self).to_dict() dictionary = super(Session, self).to_dict()
del dictionary['description'] del dictionary['description']
#object relations may be not loaded yet # object relations may be not loaded yet
if 'environment' in dictionary: if 'environment' in dictionary:
del dictionary['environment'] del dictionary['environment']
return dictionary return dictionary
@ -138,7 +138,7 @@ class Status(Base, TimestampMixin):
def to_dict(self): def to_dict(self):
dictionary = super(Status, self).to_dict() dictionary = super(Status, self).to_dict()
#object relations may be not loaded yet # object relations may be not loaded yet
if 'deployment' in dictionary: if 'deployment' in dictionary:
del dictionary['deployment'] del dictionary['deployment']
return dictionary return dictionary

View File

@ -56,7 +56,7 @@ class EnvironmentServices(object):
:param environment_id: Id of environment for which we checking status. :param environment_id: Id of environment for which we checking status.
:return: Environment 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) session_list = sessions.SessionServices.get_sessions(environment_id)
has_opened = False has_opened = False
for session in session_list: for session in session_list:
@ -77,7 +77,7 @@ class EnvironmentServices(object):
@staticmethod @staticmethod
def create(environment_params, tenant_id): 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 """Creates environment with specified params, in particular - name
:param environment_params: Dict, e.g. {'name': 'env-name'} :param environment_params: Dict, e.g. {'name': 'env-name'}
@ -106,7 +106,7 @@ class EnvironmentServices(object):
with unit.begin(): with unit.begin():
unit.add(environment) unit.add(environment)
#saving environment as Json to itself # saving environment as Json to itself
environment.update({'description': data}) environment.update({'description': data})
environment.save(unit) environment.save(unit)

View File

@ -33,13 +33,13 @@ class SessionServices(object):
# Here we duplicate logic for reducing calls to database # Here we duplicate logic for reducing calls to database
# Checks for validation is same as in validate. # Checks for validation is same as in validate.
query = unit.query(models.Session).filter( query = unit.query(models.Session).filter(
#Get all session for this environment # Get all session for this environment
models.Session.environment_id == environment_id, 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: 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), query = query.filter(models.Session.state == state),
return query.order_by(models.Session.version.desc(), return query.order_by(models.Session.version.desc(),
@ -79,17 +79,17 @@ class SessionServices(object):
:param session: Session for validation :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() unit = db_session.get_session()
#if environment version is higher then version on which current session # if environment version is higher then version on which current
#is created then other session was already deployed # session is created then other session was already deployed
current_env = unit.query(models.Environment).\ current_env = unit.query(models.Environment).\
get(session.environment_id) get(session.environment_id)
if current_env.version > session.version: if current_env.version > session.version:
return False 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( other_is_deploying = unit.query(models.Session).filter_by(
environment_id=session.environment_id, environment_id=session.environment_id,
state=states.SessionState.DEPLOYING state=states.SessionState.DEPLOYING
@ -109,8 +109,6 @@ class SessionServices(object):
:param token: auth token that is going to be used by orchestration :param token: auth token that is going to be used by orchestration
""" """
#Set X-Auth-Token for conductor
deleted = session.description['Objects'] is None deleted = session.description['Objects'] is None
action_name = None if deleted else 'deploy' action_name = None if deleted else 'deploy'
actions.ActionServices.submit_task( actions.ActionServices.submit_task(

View File

@ -96,7 +96,7 @@ def _pass1_serialize(value, parent, serialized_objects,
result = value.to_dictionary() result = value.to_dictionary()
if designer_attributes_getter is not None: if designer_attributes_getter is not None:
result['?'].update(designer_attributes_getter(value.object_id)) 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) actions = _serialize_available_action(value)
result['?']['_actions'] = _merge_actions( result['?']['_actions'] = _merge_actions(
result['?'].get('_actions', {}), actions) result['?'].get('_actions', {}), actions)

View File

@ -103,7 +103,7 @@ class ControllerTest(object):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ControllerTest, self).__init__(*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.api_version = '1.0'
self.tenant = 'test_tenant' self.tenant = 'test_tenant'
self.mock_policy_check = None self.mock_policy_check = None

View File

@ -23,7 +23,7 @@ def dummy_context(user='test_username', tenant_id='test_tenant_id',
return context.RequestContext.from_dict({ return context.RequestContext.from_dict({
'tenant': tenant_id, 'tenant': tenant_id,
'user': user, 'user': user,
#'roles': roles, # Commented until policy check changes land # 'roles': roles, # Commented until policy check changes land
'is_admin': is_admin, 'is_admin': is_admin,
}) })

View File

@ -39,13 +39,12 @@ commands = oslo-config-generator --config-file etc/oslo-config-generator/murano.
[flake8] [flake8]
# H233 Python 3.x incompatible use of print operator # H233 Python 3.x incompatible use of print operator
# E265 block comment should start with '# '
# H307 like imports should be grouped together # H307 like imports should be grouped together
# H405 Multi line docstring summary not separated with an empty line # H405 Multi line docstring summary not separated with an empty line
# H702 Argument to _ must be just a string # H702 Argument to _ must be just a string
# H904 Wrap long lines in parentheses instead of a backslash # 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 show-source = true
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools