Fix H904 pep8 error

Change-Id: I6540c5547a68721cc40b46b96da3648be00fa766
This commit is contained in:
Anastasia Kuznetsova 2015-02-06 20:12:35 +04:00
parent e4dd81a2c2
commit 8919453e10
22 changed files with 86 additions and 86 deletions

View File

@ -157,8 +157,8 @@ Mistral Workflow Service, version 0.1, 2014
def print_server_info(): def print_server_info():
print(MISTRAL_TITLE) print(MISTRAL_TITLE)
comp_str = "[%s]" % ','.join(LAUNCH_OPTIONS) \ comp_str = ("[%s]" % ','.join(LAUNCH_OPTIONS)
if cfg.CONF.server == ['all'] else cfg.CONF.server if cfg.CONF.server == ['all'] else cfg.CONF.server)
print('Launching server components %s...' % comp_str) print('Launching server components %s...' % comp_str)

View File

@ -188,15 +188,15 @@ class Engine(object):
WF_TRACE.info("Task '%s' [%s -> %s, result = %s]" % WF_TRACE.info("Task '%s' [%s -> %s, result = %s]" %
(task.name, task.state, state, result)) (task.name, task.state, state, result))
action_name = spec_parser.get_task_spec(task.task_spec)\ action_name = spec_parser.get_task_spec(
.get_full_action_name() task.task_spec).get_full_action_name()
if not a_m.get_action_class(action_name): if not a_m.get_action_class(action_name):
action = a_m.resolve_adhoc_action_name(workbook, action_name) action = a_m.resolve_adhoc_action_name(workbook, action_name)
if not action: if not action:
msg = 'Unknown action [workbook=%s, action=%s]' % \ msg = 'Unknown action [workbook=%s, action=%s]' % (
(workbook, action_name) workbook, action_name)
raise exc.ActionException(msg) raise exc.ActionException(msg)
result = a_m.convert_adhoc_action_result(workbook, result = a_m.convert_adhoc_action_result(workbook,

View File

@ -89,8 +89,8 @@ def prepare_tasks(tasks_to_start, context, workbook, tasks):
# Get action name. Unwrap ad-hoc and reevaluate params if # Get action name. Unwrap ad-hoc and reevaluate params if
# necessary. # necessary.
action_name = spec_parser.get_task_spec(task.task_spec)\ action_name = spec_parser.get_task_spec(
.get_full_action_name() task.task_spec).get_full_action_name()
openstack_ctx = context.get('openstack') openstack_ctx = context.get('openstack')
@ -103,8 +103,8 @@ def prepare_tasks(tasks_to_start, context, workbook, tasks):
action = a_m.resolve_adhoc_action_name(workbook, action_name) action = a_m.resolve_adhoc_action_name(workbook, action_name)
if not action: if not action:
msg = 'Unknown action [workbook=%s, action=%s]' % \ msg = ('Unknown action [workbook=%s, action=%s]' %
(workbook, action_name) (workbook, action_name))
raise exc.ActionException(msg) raise exc.ActionException(msg)
action_params = a_m.convert_adhoc_action_params(workbook, action_params = a_m.convert_adhoc_action_params(workbook,
@ -113,8 +113,8 @@ def prepare_tasks(tasks_to_start, context, workbook, tasks):
action_name = action action_name = action
if _has_action_context_param(a_m.get_action_class(action_name)): if _has_action_context_param(a_m.get_action_class(action_name)):
action_params[_ACTION_CTX_PARAM] = \ action_params[_ACTION_CTX_PARAM] = _get_action_context(
_get_action_context(task, openstack_ctx) task, openstack_ctx)
results.append((task.id, action_name, action_params)) results.append((task.id, action_name, action_params))

View File

@ -61,8 +61,8 @@ def get_task_runtime(task_spec, state=states.IDLE, outbound_context=None,
retry_count, break_on, delay = task_spec.get_retry_parameters() retry_count, break_on, delay = task_spec.get_retry_parameters()
retries_remain = retry_no + 1 < retry_count retries_remain = retry_no + 1 < retry_count
break_early = expressions.evaluate(break_on, outbound_context) if \ break_early = (expressions.evaluate(break_on, outbound_context)
break_on and outbound_context else False if break_on and outbound_context else False)
if retries_remain and not break_early: if retries_remain and not break_early:
state = states.DELAYED if delay > 0 else states.IDLE state = states.DELAYED if delay > 0 else states.IDLE

View File

@ -337,5 +337,5 @@ RESERVED_COMMANDS = {
def get_reserved_command(cmd_name): def get_reserved_command(cmd_name):
return RESERVED_COMMANDS[cmd_name]() if cmd_name in RESERVED_COMMANDS \ return (RESERVED_COMMANDS[cmd_name]()
else None if cmd_name in RESERVED_COMMANDS else None)

View File

@ -109,11 +109,11 @@ def transform_result(exec_db, task_db, raw_result):
if raw_result.is_error(): if raw_result.is_error():
return raw_result return raw_result
action_spec_name =\ action_spec_name = spec_parser.get_task_spec(
spec_parser.get_task_spec(task_db.spec).get_action_name() task_db.spec).get_action_name()
wf_spec_name = \ wf_spec_name = spec_parser.get_workflow_spec(
spec_parser.get_workflow_spec(exec_db.wf_spec).get_name() exec_db.wf_spec).get_name()
if action_spec_name: if action_spec_name:
return transform_action_result( return transform_action_result(

View File

@ -127,8 +127,8 @@ _EVALUATOR = InlineYAQLEvaluator
def evaluate(expression, context): def evaluate(expression, context):
# Check if the passed value is expression so we don't need to do this # Check if the passed value is expression so we don't need to do this
# every time on a caller side. # every time on a caller side.
if not isinstance(expression, six.string_types) or \ if (not isinstance(expression, six.string_types) or
not _EVALUATOR.is_expression(expression): not _EVALUATOR.is_expression(expression)):
return expression return expression
return _EVALUATOR.evaluate(expression, context) return _EVALUATOR.evaluate(expression, context)

View File

@ -174,17 +174,17 @@ def resolve_adhoc_action_name(workbook, action_name):
action_spec = workbook.get_action(action_name) action_spec = workbook.get_action(action_name)
if not action_spec: if not action_spec:
msg = 'Ad-hoc action class is not registered ' \ msg = ('Ad-hoc action class is not registered '
'[workbook=%s, action=%s, action_spec=%s]' % \ '[workbook=%s, action=%s, action_spec=%s]' %
(workbook, action_name, action_spec) (workbook, action_name, action_spec))
raise exc.ActionException(msg) raise exc.ActionException(msg)
base_cls = get_action_class(action_spec.clazz) base_cls = get_action_class(action_spec.clazz)
if not base_cls: if not base_cls:
msg = 'Ad-hoc action base class is not registered ' \ msg = ('Ad-hoc action base class is not registered '
'[workbook=%s, action=%s, base_class=%s]' % \ '[workbook=%s, action=%s, base_class=%s]' %
(workbook, action_name, base_cls) (workbook, action_name, base_cls))
raise exc.ActionException(msg) raise exc.ActionException(msg)
return action_spec.clazz return action_spec.clazz

View File

@ -29,6 +29,7 @@ LOG = log.getLogger(__name__)
def schedule_call(factory_method_path, target_method_name, def schedule_call(factory_method_path, target_method_name,
run_after, serializers=None, **method_args): run_after, serializers=None, **method_args):
"""Add this call specification to DB, and then after run_after """Add this call specification to DB, and then after run_after
seconds service CallScheduler invokes the target_method. seconds service CallScheduler invokes the target_method.

View File

@ -93,8 +93,8 @@ class BaseTest(base.BaseTestCase):
def _assert_multiple_items(self, items, count, **props): def _assert_multiple_items(self, items, count, **props):
def _matches(item, **props): def _matches(item, **props):
for prop_name, prop_val in props.iteritems(): for prop_name, prop_val in props.iteritems():
v = item[prop_name] if isinstance(item, dict) \ v = item[prop_name] if isinstance(
else getattr(item, prop_name) item, dict) else getattr(item, prop_name)
if v != prop_val: if v != prop_val:
return False return False

View File

@ -180,15 +180,15 @@ class MistralClientV1(MistralClientBase):
while ex_body['state'] != 'SUCCESS': while ex_body['state'] != 'SUCCESS':
if time.time() - start_time > timeout: if time.time() - start_time > timeout:
msg = "Execution exceeds timeout {0} to change state " \ msg = ("Execution exceeds timeout {0} to change state "
"to SUCCESS. Execution: {1}".format(timeout, ex_body) "to SUCCESS. Execution: {1}".format(timeout, ex_body))
raise exceptions.TimeoutException(msg) raise exceptions.TimeoutException(msg)
_, ex_body = self.get_object('executions', ex_body['id']) _, ex_body = self.get_object('executions', ex_body['id'])
if ex_body['state'] not in expected_states: if ex_body['state'] not in expected_states:
msg = "Execution state %s is not in expected " \ msg = ("Execution state %s is not in expected "
"states: %s" % (ex_body['state'], expected_states) "states: %s" % (ex_body['state'], expected_states))
raise exceptions.TempestException(msg) raise exceptions.TempestException(msg)
time.sleep(2) time.sleep(2)

View File

@ -36,8 +36,8 @@ TRIGGER = {
} }
trigger_values = copy.copy(TRIGGER) trigger_values = copy.copy(TRIGGER)
trigger_values['workflow_input'] = \ trigger_values['workflow_input'] = json.loads(
json.loads(trigger_values['workflow_input']) trigger_values['workflow_input'])
TRIGGER_DB = models.CronTrigger() TRIGGER_DB = models.CronTrigger()
TRIGGER_DB.update(trigger_values) TRIGGER_DB.update(trigger_values)

View File

@ -74,11 +74,11 @@ class TestEngine(base.EngineTestCase):
task = db_api.tasks_get(workbook_name=WB_NAME, task = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])[0] execution_id=execution['id'])[0]
executor.ExecutorClient.handle_task \ executor.ExecutorClient.handle_task.assert_called_once_with(
.assert_called_once_with(auth_context.ctx(), auth_context.ctx(),
params={'output': 'Stormin Stanley'}, params={'output': 'Stormin Stanley'},
task_id=task['id'], task_id=task['id'],
action_name='std.echo') action_name='std.echo')
self.engine.convey_task_result(task['id'], self.engine.convey_task_result(task['id'],
states.SUCCESS, states.SUCCESS,

View File

@ -142,10 +142,10 @@ class TestExecutor(base.DbTestCase):
action_name=action_name, action_name=action_name,
params=params) params=params)
engine.EngineClient.convey_task_result\ engine.EngineClient.convey_task_result.assert_called_once_with(
.assert_called_once_with(task_id, task_id,
states.SUCCESS, states.SUCCESS,
action.return_value) action.return_value)
@mock.patch.object(engine.EngineClient, 'convey_task_result', @mock.patch.object(engine.EngineClient, 'convey_task_result',
mock.MagicMock()) mock.MagicMock())
@ -187,7 +187,5 @@ class TestExecutor(base.DbTestCase):
params=params) params=params)
self.assertTrue(log.called, "Exception must be logged") self.assertTrue(log.called, "Exception must be logged")
engine.EngineClient.convey_task_result\ engine.EngineClient.convey_task_result.assert_called_once_with(
.assert_called_once_with(task_id, task_id, states.ERROR, None)
states.ERROR,
None)

View File

@ -107,10 +107,10 @@ class DataFlowTest(base.EngineTestCase):
self.assertEqual(2, len(tasks)) self.assertEqual(2, len(tasks))
build_full_name_task = \ build_full_name_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_full_name') tasks, name='build_full_name')
build_greeting_task = \ build_greeting_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_greeting') tasks, name='build_greeting')
# Check the first task. # Check the first task.
self.assertEqual(states.SUCCESS, build_full_name_task['state']) self.assertEqual(states.SUCCESS, build_full_name_task['state'])
@ -175,12 +175,12 @@ class DataFlowTest(base.EngineTestCase):
self.assertEqual(3, len(tasks)) self.assertEqual(3, len(tasks))
build_full_name_task = \ build_full_name_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_full_name') tasks, name='build_full_name')
build_greeting_task = \ build_greeting_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_greeting') tasks, name='build_greeting')
send_greeting_task = \ send_greeting_task = self._assert_single_item(
self._assert_single_item(tasks, name='send_greeting') tasks, name='send_greeting')
# Check the first task. # Check the first task.
self.assertEqual(states.SUCCESS, build_full_name_task['state']) self.assertEqual(states.SUCCESS, build_full_name_task['state'])
@ -312,10 +312,10 @@ class DataFlowTest(base.EngineTestCase):
self.assertEqual(2, len(tasks)) self.assertEqual(2, len(tasks))
build_full_name_task = \ build_full_name_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_full_name') tasks, name='build_full_name')
build_greeting_task = \ build_greeting_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_greeting') tasks, name='build_greeting')
# Check the first task. # Check the first task.
self.assertEqual(states.SUCCESS, build_full_name_task['state']) self.assertEqual(states.SUCCESS, build_full_name_task['state'])
@ -385,12 +385,12 @@ class DataFlowTest(base.EngineTestCase):
self.assertEqual(3, len(tasks)) self.assertEqual(3, len(tasks))
build_full_name_task = \ build_full_name_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_full_name') tasks, name='build_full_name')
build_greeting_task = \ build_greeting_task = self._assert_single_item(
self._assert_single_item(tasks, name='build_greeting') tasks, name='build_greeting')
send_greeting_task = \ send_greeting_task = self._assert_single_item(
self._assert_single_item(tasks, name='send_greeting') tasks, name='send_greeting')
# Check the first task. # Check the first task.
self.assertEqual(states.SUCCESS, build_full_name_task['state']) self.assertEqual(states.SUCCESS, build_full_name_task['state'])

View File

@ -70,8 +70,8 @@ def set_thread_local(var_name, val):
if val: if val:
gl_storage = _get_greenlet_local_storage() gl_storage = _get_greenlet_local_storage()
if not gl_storage: if not gl_storage:
gl_storage = \ gl_storage = _th_loc_storage.greenlet_locals[
_th_loc_storage.greenlet_locals[corolocal.get_ident()] = {} corolocal.get_ident()] = {}
gl_storage[var_name] = val gl_storage[var_name] = val
@ -83,11 +83,11 @@ def log_exec(logger, level=logging.DEBUG):
def _decorator(func): def _decorator(func):
def _logged(*args, **kw): def _logged(*args, **kw):
params_repr = "[args=%s, kw=%s]" % (str(args), str(kw)) \ params_repr = ("[args=%s, kw=%s]" % (str(args), str(kw))
if len(args) > 0 or len(kw) > 0 else "" if len(args) > 0 or len(kw) > 0 else "")
func_repr = "Called method [name=%s, doc='%s', params=%s]" % \ func_repr = ("Called method [name=%s, doc='%s', params=%s]" %
(func.__name__, func.__doc__, params_repr) (func.__name__, func.__doc__, params_repr))
logger.log(level, func_repr) logger.log(level, func_repr)

View File

@ -46,8 +46,8 @@ class WorkbookSpec(base.BaseSpec):
self._description = data.get('description') self._description = data.get('description')
self._tags = data.get('tags', []) self._tags = data.get('tags', [])
self._actions = self._spec_property('actions', act.ActionSpecList) self._actions = self._spec_property('actions', act.ActionSpecList)
self._workflows = \ self._workflows = self._spec_property(
self._spec_property('workflows', wf.WorkflowSpecList) 'workflows', wf.WorkflowSpecList)
self._triggers = self._spec_property('triggers', tr.TriggerSpecList) self._triggers = self._spec_property('triggers', tr.TriggerSpecList)
def get_name(self): def get_name(self):

View File

@ -301,8 +301,9 @@ class WorkflowHandler(object):
self.exec_db.state = state self.exec_db.state = state
self.exec_db.state_info = state_info self.exec_db.state_info = state_info
else: else:
msg = "Can't change workflow state [execution=%s," \ msg = ("Can't change workflow state "
" state=%s -> %s]" % (self.exec_db, cur_state, state) "[execution=%s, state=%s -> %s]" %
(self.exec_db, cur_state, state))
raise exc.WorkflowException(msg) raise exc.WorkflowException(msg)

View File

@ -132,8 +132,8 @@ def evaluate_task_outbound_context(task_db):
:return: Outbound task Data Flow context. :return: Outbound task Data Flow context.
""" """
in_context = copy.deepcopy(dict(task_db.in_context)) \ in_context = (copy.deepcopy(dict(task_db.in_context))
if task_db.in_context is not None else {} if task_db.in_context is not None else {})
out_ctx = utils.merge_dicts(in_context, task_db.output) out_ctx = utils.merge_dicts(in_context, task_db.output)

View File

@ -42,8 +42,8 @@ class ReverseWorkflowHandler(base.WorkflowHandler):
task_spec = self.wf_spec.get_tasks().get(task_name) task_spec = self.wf_spec.get_tasks().get(task_name)
if not task_spec: if not task_spec:
msg = 'Invalid task name [wf_spec=%s, task_name=%s]' % \ msg = 'Invalid task name [wf_spec=%s, task_name=%s]' % (
(self.wf_spec, task_name) self.wf_spec, task_name)
raise exc.WorkflowException(msg) raise exc.WorkflowException(msg)
task_specs = self._find_tasks_without_dependencies(task_spec) task_specs = self._find_tasks_without_dependencies(task_spec)

View File

@ -24,8 +24,8 @@ class TaskResult(object):
self.error = error self.error = error
def __repr__(self): def __repr__(self):
return 'TaskResult [data=%s, error=%s]' % \ return 'TaskResult [data=%s, error=%s]' % (
(repr(self.data), repr(self.error)) repr(self.data), repr(self.error))
def is_error(self): def is_error(self):
return self.error is not None return self.error is not None

View File

@ -41,6 +41,6 @@ commands = bash tools/lintstack.sh
[flake8] [flake8]
show-source = true show-source = true
ignore = H803,H305,H405,H904 ignore = H803,H305,H405
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,scripts exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,scripts