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']] entities = [u['id'] for u in service['units']]
reports_count = unit.query(models.Status).filter( reports_count = unit.query(models.Status).filter(
models.Status.environment_id == environment_id models.Status.environment_id == environment_id and
and models.Status.session_id == session_id models.Status.session_id == session_id and
and models.Status.entity_id.in_(entities) models.Status.entity_id.in_(entities)
).count() ).count()
if session_state == 'deployed': if session_state == 'deployed':

View File

@@ -20,19 +20,6 @@ import sys
import eventlet 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_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_service import service from oslo_service import service
@@ -48,6 +35,20 @@ from murano.common import wsgi
CONF = cfg.CONF 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(): def main():
try: try:
config.parse_args() config.parse_args()

View File

@@ -20,19 +20,6 @@ import sys
import eventlet 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_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_service import service from oslo_service import service
@@ -47,6 +34,20 @@ from murano.common import wsgi
CONF = cfg.CONF 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(): def main():
try: try:
config.parse_args() config.parse_args()

View File

@@ -19,6 +19,14 @@ import sys
import eventlet 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': if os.name == 'nt':
# eventlet monkey patching causes subprocess.Popen to fail on Windows # 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')): if os.path.exists(os.path.join(root, 'murano', '__init__.py')):
sys.path.insert(0, root) 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(): def main():
try: try:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -201,10 +201,10 @@ class MuranoObject(dsl_types.MuranoObject):
values_to_assign = [] values_to_assign = []
for mc in declared_properties: for mc in declared_properties:
spec = mc.get_property(name) spec = mc.get_property(name)
if (caller_class is not None and if (caller_class is not None and not
not helpers.are_property_modifications_allowed(context) helpers.are_property_modifications_allowed(context) and
and (spec.usage not in typespec.PropertyUsages.Writable (spec.usage not in typespec.PropertyUsages.Writable or
or not derived)): not derived)):
raise exceptions.NoWriteAccessError(name) raise exceptions.NoWriteAccessError(name)
default = self.__config.get(name, spec.default) 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: if value.owner is not parent or value.object_id in serialized_objects:
return ObjRef(value), True return ObjRef(value), True
elif isinstance(value, ObjRef): elif isinstance(value, ObjRef):
if (value.ref_obj.object_id not in serialized_objects if (value.ref_obj.object_id not in serialized_objects and
and is_nested_in(value.ref_obj.owner, parent)): is_nested_in(value.ref_obj.owner, parent)):
value = value.ref_obj value = value.ref_obj
else: else:
return value, False return value, False
@@ -139,8 +139,8 @@ def _pass3_serialize(value, serialized_objects, allow_refs=False):
if isinstance(value, dict): if isinstance(value, dict):
for d_key, d_value in value.items(): for d_key, d_value in value.items():
if isinstance(d_value, ObjRef): if isinstance(d_value, ObjRef):
if (d_value.ref_obj.object_id in serialized_objects if (d_value.ref_obj.object_id in serialized_objects or
or allow_refs): allow_refs):
value[d_key] = d_value.ref_obj.object_id value[d_key] = d_value.ref_obj.object_id
else: else:
del value[d_key] del value[d_key]

View File

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