Fix the run_test unchecked pep8 W503 and E402 errors

Now thw flake8 did not check W503 and E402 errors,
1.E402 module level import not at top of file
2.W503 line break before binary operator
This patch fix it

Change-Id: Ieae4f2f23d2aa0fd1e19ef770c2f1ce6aef30f79
This commit is contained in:
zhu.rong 2015-09-25 14:13:17 +08:00
parent c9cc6a95a2
commit 8d2a8933ce
14 changed files with 65 additions and 60 deletions

View File

@ -62,9 +62,9 @@ def get_service_status(environment_id, session_id, service):
entities = [u['id'] for u in service['units']]
reports_count = unit.query(models.Status).filter(
models.Status.environment_id == environment_id
and models.Status.session_id == session_id
and models.Status.entity_id.in_(entities)
models.Status.environment_id == environment_id and
models.Status.session_id == session_id and
models.Status.entity_id.in_(entities)
).count()
if session_state == 'deployed':

View File

@ -20,19 +20,6 @@ import sys
import eventlet
if os.name == 'nt':
# eventlet monkey patching causes subprocess.Popen to fail on Windows
# when using pipes due to missing non blocking I/O support
eventlet.monkey_patch(os=False)
else:
eventlet.monkey_patch()
# If ../murano/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir)
if os.path.exists(os.path.join(root, 'murano', '__init__.py')):
sys.path.insert(0, root)
from oslo_config import cfg
from oslo_log import log as logging
from oslo_service import service
@ -48,6 +35,20 @@ from murano.common import wsgi
CONF = cfg.CONF
if os.name == 'nt':
# eventlet monkey patching causes subprocess.Popen to fail on Windows
# when using pipes due to missing non blocking I/O support
eventlet.monkey_patch(os=False)
else:
eventlet.monkey_patch()
# If ../murano/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir)
if os.path.exists(os.path.join(root, 'murano', '__init__.py')):
sys.path.insert(0, root)
def main():
try:
config.parse_args()

View File

@ -20,19 +20,6 @@ import sys
import eventlet
if os.name == 'nt':
# eventlet monkey patching causes subprocess.Popen to fail on Windows
# when using pipes due to missing non blocking I/O support
eventlet.monkey_patch(os=False)
else:
eventlet.monkey_patch()
# If ../murano/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir)
if os.path.exists(os.path.join(root, 'murano', '__init__.py')):
sys.path.insert(0, root)
from oslo_config import cfg
from oslo_log import log as logging
from oslo_service import service
@ -47,6 +34,20 @@ from murano.common import wsgi
CONF = cfg.CONF
if os.name == 'nt':
# eventlet monkey patching causes subprocess.Popen to fail on Windows
# when using pipes due to missing non blocking I/O support
eventlet.monkey_patch(os=False)
else:
eventlet.monkey_patch()
# If ../murano/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir)
if os.path.exists(os.path.join(root, 'murano', '__init__.py')):
sys.path.insert(0, root)
def main():
try:
config.parse_args()

View File

@ -19,6 +19,14 @@ import sys
import eventlet
from oslo_log import log as logging
from oslo_service import service
from murano.common import config
from murano.common import engine
CONF = config.CONF
if os.name == 'nt':
# eventlet monkey patching causes subprocess.Popen to fail on Windows
@ -33,14 +41,6 @@ root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir)
if os.path.exists(os.path.join(root, 'murano', '__init__.py')):
sys.path.insert(0, root)
from oslo_log import log as logging
from oslo_service import service
from murano.common import config
from murano.common import engine
CONF = config.CONF
def main():
try:

View File

@ -148,8 +148,8 @@ class TaskExecutor(object):
self._model['SystemData'] = self._environment.system_attributes
result['model'] = self._model
if (not self._model.get('Objects')
and not self._model.get('ObjectsCopy')):
if (not self._model.get('Objects') and
not self._model.get('ObjectsCopy')):
try:
self._delete_trust()
except Exception:

View File

@ -16,10 +16,11 @@
import ssl as ssl_module
from eventlet import patcher
kombu = patcher.import_patched('kombu')
from oslo_serialization import jsonutils
from subscription import Subscription
kombu = patcher.import_patched('kombu')
class MqClient(object):
def __init__(self, login, password, host, port, virtual_host,

View File

@ -18,9 +18,10 @@ import socket
import time
from eventlet import patcher
kombu = patcher.import_patched('kombu')
from murano.common.messaging import message
kombu = patcher.import_patched('kombu')
class Subscription(object):
def __init__(self, connection, queue, prefetch_count=1):

View File

@ -166,8 +166,8 @@ def is_different(obj1, obj2):
if o1 is o2:
return
elif (isinstance(o1, basestring)
and isinstance(o2, basestring)) and o1 == o2:
elif (isinstance(o1, basestring) and
isinstance(o2, basestring)) and o1 == o2:
return
elif type(o1) != type(o2):
raise Difference()

View File

@ -25,7 +25,6 @@ from xml.dom import minidom
from xml.parsers import expat
import eventlet
eventlet.patcher.monkey_patch(all=False, socket=True)
import eventlet.wsgi
import jsonschema
from oslo_config import cfg
@ -44,6 +43,8 @@ from murano.common import exceptions
from murano.common.i18n import _, _LE, _LW
from murano.common import xmlutils
eventlet.patcher.monkey_patch(all=False, socket=True)
wsgi_opts = [
cfg.IntOpt('backlog',
default=4096,

View File

@ -107,8 +107,8 @@ class MuranoDslExecutor(object):
return (None if method.body is None
else method.body.execute(context))
if (not isinstance(method.body, specs.FunctionDefinition)
or not method.body.meta.get(constants.META_NO_TRACE)):
if (not isinstance(method.body, specs.FunctionDefinition) or
not method.body.meta.get(constants.META_NO_TRACE)):
with self._log_method(context, args, kwargs) as log:
result = call()
log(result)

View File

@ -50,8 +50,8 @@ class MuranoMethod(dsl_types.MuranoMethod):
self._usage = (self._body.meta.get('usage') or
self._body.meta.get('Usage') or
MethodUsages.Runtime)
if (self._body.name.startswith('#')
or self._body.name.startswith('*')):
if (self._body.name.startswith('#') or
self._body.name.startswith('*')):
raise ValueError(
'Import of special yaql functions is forbidden')
else:
@ -64,8 +64,8 @@ class MuranoMethod(dsl_types.MuranoMethod):
arguments_scheme.iteritems()]
self._arguments_scheme = collections.OrderedDict()
for record in arguments_scheme:
if (not isinstance(record, types.DictionaryType)
or len(record) > 1):
if (not isinstance(record, types.DictionaryType) or
len(record) > 1):
raise ValueError()
name = record.keys()[0]
self._arguments_scheme[name] = typespec.ArgumentSpec(

View File

@ -201,10 +201,10 @@ class MuranoObject(dsl_types.MuranoObject):
values_to_assign = []
for mc in declared_properties:
spec = mc.get_property(name)
if (caller_class is not None and
not helpers.are_property_modifications_allowed(context)
and (spec.usage not in typespec.PropertyUsages.Writable
or not derived)):
if (caller_class is not None and not
helpers.are_property_modifications_allowed(context) and
(spec.usage not in typespec.PropertyUsages.Writable or
not derived)):
raise exceptions.NoWriteAccessError(name)
default = self.__config.get(name, spec.default)

View File

@ -93,8 +93,8 @@ def _pass12_serialize(value, parent, serialized_objects,
if value.owner is not parent or value.object_id in serialized_objects:
return ObjRef(value), True
elif isinstance(value, ObjRef):
if (value.ref_obj.object_id not in serialized_objects
and is_nested_in(value.ref_obj.owner, parent)):
if (value.ref_obj.object_id not in serialized_objects and
is_nested_in(value.ref_obj.owner, parent)):
value = value.ref_obj
else:
return value, False
@ -139,8 +139,8 @@ def _pass3_serialize(value, serialized_objects, allow_refs=False):
if isinstance(value, dict):
for d_key, d_value in value.items():
if isinstance(d_value, ObjRef):
if (d_value.ref_obj.object_id in serialized_objects
or allow_refs):
if (d_value.ref_obj.object_id in serialized_objects or
allow_refs):
value[d_key] = d_value.ref_obj.object_id
else:
del value[d_key]

View File

@ -91,8 +91,8 @@ class RemoveObjectAction(base.ModifyActionBase, ActionUtils):
# remove object from dict
elif isinstance(val, utils.FrozenDict):
filtered_dict = {k: v for k, v in val.items() if not
self._match_object_id(self._object_id, k)
and not
self._match_object_id(self._object_id,
k) and not
self._match_object_id(self._object_id, v)}
if len(filtered_dict) < len(val):
_obj.set_property(prop_name,