Fix H904 pep8 error
Change-Id: I6540c5547a68721cc40b46b96da3648be00fa766
This commit is contained in:
parent
e4dd81a2c2
commit
8919453e10
@ -157,8 +157,8 @@ Mistral Workflow Service, version 0.1, 2014
|
||||
def print_server_info():
|
||||
print(MISTRAL_TITLE)
|
||||
|
||||
comp_str = "[%s]" % ','.join(LAUNCH_OPTIONS) \
|
||||
if cfg.CONF.server == ['all'] else cfg.CONF.server
|
||||
comp_str = ("[%s]" % ','.join(LAUNCH_OPTIONS)
|
||||
if cfg.CONF.server == ['all'] else cfg.CONF.server)
|
||||
|
||||
print('Launching server components %s...' % comp_str)
|
||||
|
||||
|
@ -188,15 +188,15 @@ class Engine(object):
|
||||
WF_TRACE.info("Task '%s' [%s -> %s, result = %s]" %
|
||||
(task.name, task.state, state, result))
|
||||
|
||||
action_name = spec_parser.get_task_spec(task.task_spec)\
|
||||
.get_full_action_name()
|
||||
action_name = spec_parser.get_task_spec(
|
||||
task.task_spec).get_full_action_name()
|
||||
|
||||
if not a_m.get_action_class(action_name):
|
||||
action = a_m.resolve_adhoc_action_name(workbook, action_name)
|
||||
|
||||
if not action:
|
||||
msg = 'Unknown action [workbook=%s, action=%s]' % \
|
||||
(workbook, action_name)
|
||||
msg = 'Unknown action [workbook=%s, action=%s]' % (
|
||||
workbook, action_name)
|
||||
raise exc.ActionException(msg)
|
||||
|
||||
result = a_m.convert_adhoc_action_result(workbook,
|
||||
|
@ -89,8 +89,8 @@ def prepare_tasks(tasks_to_start, context, workbook, tasks):
|
||||
|
||||
# Get action name. Unwrap ad-hoc and reevaluate params if
|
||||
# necessary.
|
||||
action_name = spec_parser.get_task_spec(task.task_spec)\
|
||||
.get_full_action_name()
|
||||
action_name = spec_parser.get_task_spec(
|
||||
task.task_spec).get_full_action_name()
|
||||
|
||||
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)
|
||||
|
||||
if not action:
|
||||
msg = 'Unknown action [workbook=%s, action=%s]' % \
|
||||
(workbook, action_name)
|
||||
msg = ('Unknown action [workbook=%s, action=%s]' %
|
||||
(workbook, action_name))
|
||||
raise exc.ActionException(msg)
|
||||
|
||||
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
|
||||
|
||||
if _has_action_context_param(a_m.get_action_class(action_name)):
|
||||
action_params[_ACTION_CTX_PARAM] = \
|
||||
_get_action_context(task, openstack_ctx)
|
||||
action_params[_ACTION_CTX_PARAM] = _get_action_context(
|
||||
task, openstack_ctx)
|
||||
|
||||
results.append((task.id, action_name, action_params))
|
||||
|
||||
|
@ -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()
|
||||
|
||||
retries_remain = retry_no + 1 < retry_count
|
||||
break_early = expressions.evaluate(break_on, outbound_context) if \
|
||||
break_on and outbound_context else False
|
||||
break_early = (expressions.evaluate(break_on, outbound_context)
|
||||
if break_on and outbound_context else False)
|
||||
|
||||
if retries_remain and not break_early:
|
||||
state = states.DELAYED if delay > 0 else states.IDLE
|
||||
|
@ -337,5 +337,5 @@ RESERVED_COMMANDS = {
|
||||
|
||||
|
||||
def get_reserved_command(cmd_name):
|
||||
return RESERVED_COMMANDS[cmd_name]() if cmd_name in RESERVED_COMMANDS \
|
||||
else None
|
||||
return (RESERVED_COMMANDS[cmd_name]()
|
||||
if cmd_name in RESERVED_COMMANDS else None)
|
||||
|
@ -109,11 +109,11 @@ def transform_result(exec_db, task_db, raw_result):
|
||||
if raw_result.is_error():
|
||||
return raw_result
|
||||
|
||||
action_spec_name =\
|
||||
spec_parser.get_task_spec(task_db.spec).get_action_name()
|
||||
action_spec_name = spec_parser.get_task_spec(
|
||||
task_db.spec).get_action_name()
|
||||
|
||||
wf_spec_name = \
|
||||
spec_parser.get_workflow_spec(exec_db.wf_spec).get_name()
|
||||
wf_spec_name = spec_parser.get_workflow_spec(
|
||||
exec_db.wf_spec).get_name()
|
||||
|
||||
if action_spec_name:
|
||||
return transform_action_result(
|
||||
|
@ -127,8 +127,8 @@ _EVALUATOR = InlineYAQLEvaluator
|
||||
def evaluate(expression, context):
|
||||
# Check if the passed value is expression so we don't need to do this
|
||||
# every time on a caller side.
|
||||
if not isinstance(expression, six.string_types) or \
|
||||
not _EVALUATOR.is_expression(expression):
|
||||
if (not isinstance(expression, six.string_types) or
|
||||
not _EVALUATOR.is_expression(expression)):
|
||||
return expression
|
||||
|
||||
return _EVALUATOR.evaluate(expression, context)
|
||||
|
@ -174,17 +174,17 @@ def resolve_adhoc_action_name(workbook, action_name):
|
||||
action_spec = workbook.get_action(action_name)
|
||||
|
||||
if not action_spec:
|
||||
msg = 'Ad-hoc action class is not registered ' \
|
||||
'[workbook=%s, action=%s, action_spec=%s]' % \
|
||||
(workbook, action_name, action_spec)
|
||||
msg = ('Ad-hoc action class is not registered '
|
||||
'[workbook=%s, action=%s, action_spec=%s]' %
|
||||
(workbook, action_name, action_spec))
|
||||
raise exc.ActionException(msg)
|
||||
|
||||
base_cls = get_action_class(action_spec.clazz)
|
||||
|
||||
if not base_cls:
|
||||
msg = 'Ad-hoc action base class is not registered ' \
|
||||
'[workbook=%s, action=%s, base_class=%s]' % \
|
||||
(workbook, action_name, base_cls)
|
||||
msg = ('Ad-hoc action base class is not registered '
|
||||
'[workbook=%s, action=%s, base_class=%s]' %
|
||||
(workbook, action_name, base_cls))
|
||||
raise exc.ActionException(msg)
|
||||
|
||||
return action_spec.clazz
|
||||
|
@ -29,6 +29,7 @@ LOG = log.getLogger(__name__)
|
||||
|
||||
def schedule_call(factory_method_path, target_method_name,
|
||||
run_after, serializers=None, **method_args):
|
||||
|
||||
"""Add this call specification to DB, and then after run_after
|
||||
seconds service CallScheduler invokes the target_method.
|
||||
|
||||
|
@ -93,8 +93,8 @@ class BaseTest(base.BaseTestCase):
|
||||
def _assert_multiple_items(self, items, count, **props):
|
||||
def _matches(item, **props):
|
||||
for prop_name, prop_val in props.iteritems():
|
||||
v = item[prop_name] if isinstance(item, dict) \
|
||||
else getattr(item, prop_name)
|
||||
v = item[prop_name] if isinstance(
|
||||
item, dict) else getattr(item, prop_name)
|
||||
|
||||
if v != prop_val:
|
||||
return False
|
||||
|
@ -180,15 +180,15 @@ class MistralClientV1(MistralClientBase):
|
||||
|
||||
while ex_body['state'] != 'SUCCESS':
|
||||
if time.time() - start_time > timeout:
|
||||
msg = "Execution exceeds timeout {0} to change state " \
|
||||
"to SUCCESS. Execution: {1}".format(timeout, ex_body)
|
||||
msg = ("Execution exceeds timeout {0} to change state "
|
||||
"to SUCCESS. Execution: {1}".format(timeout, ex_body))
|
||||
raise exceptions.TimeoutException(msg)
|
||||
|
||||
_, ex_body = self.get_object('executions', ex_body['id'])
|
||||
|
||||
if ex_body['state'] not in expected_states:
|
||||
msg = "Execution state %s is not in expected " \
|
||||
"states: %s" % (ex_body['state'], expected_states)
|
||||
msg = ("Execution state %s is not in expected "
|
||||
"states: %s" % (ex_body['state'], expected_states))
|
||||
raise exceptions.TempestException(msg)
|
||||
|
||||
time.sleep(2)
|
||||
|
@ -36,8 +36,8 @@ TRIGGER = {
|
||||
}
|
||||
|
||||
trigger_values = copy.copy(TRIGGER)
|
||||
trigger_values['workflow_input'] = \
|
||||
json.loads(trigger_values['workflow_input'])
|
||||
trigger_values['workflow_input'] = json.loads(
|
||||
trigger_values['workflow_input'])
|
||||
|
||||
TRIGGER_DB = models.CronTrigger()
|
||||
TRIGGER_DB.update(trigger_values)
|
||||
|
@ -74,11 +74,11 @@ class TestEngine(base.EngineTestCase):
|
||||
task = db_api.tasks_get(workbook_name=WB_NAME,
|
||||
execution_id=execution['id'])[0]
|
||||
|
||||
executor.ExecutorClient.handle_task \
|
||||
.assert_called_once_with(auth_context.ctx(),
|
||||
params={'output': 'Stormin Stanley'},
|
||||
task_id=task['id'],
|
||||
action_name='std.echo')
|
||||
executor.ExecutorClient.handle_task.assert_called_once_with(
|
||||
auth_context.ctx(),
|
||||
params={'output': 'Stormin Stanley'},
|
||||
task_id=task['id'],
|
||||
action_name='std.echo')
|
||||
|
||||
self.engine.convey_task_result(task['id'],
|
||||
states.SUCCESS,
|
||||
|
@ -142,10 +142,10 @@ class TestExecutor(base.DbTestCase):
|
||||
action_name=action_name,
|
||||
params=params)
|
||||
|
||||
engine.EngineClient.convey_task_result\
|
||||
.assert_called_once_with(task_id,
|
||||
states.SUCCESS,
|
||||
action.return_value)
|
||||
engine.EngineClient.convey_task_result.assert_called_once_with(
|
||||
task_id,
|
||||
states.SUCCESS,
|
||||
action.return_value)
|
||||
|
||||
@mock.patch.object(engine.EngineClient, 'convey_task_result',
|
||||
mock.MagicMock())
|
||||
@ -187,7 +187,5 @@ class TestExecutor(base.DbTestCase):
|
||||
params=params)
|
||||
self.assertTrue(log.called, "Exception must be logged")
|
||||
|
||||
engine.EngineClient.convey_task_result\
|
||||
.assert_called_once_with(task_id,
|
||||
states.ERROR,
|
||||
None)
|
||||
engine.EngineClient.convey_task_result.assert_called_once_with(
|
||||
task_id, states.ERROR, None)
|
||||
|
@ -107,10 +107,10 @@ class DataFlowTest(base.EngineTestCase):
|
||||
|
||||
self.assertEqual(2, len(tasks))
|
||||
|
||||
build_full_name_task = \
|
||||
self._assert_single_item(tasks, name='build_full_name')
|
||||
build_greeting_task = \
|
||||
self._assert_single_item(tasks, name='build_greeting')
|
||||
build_full_name_task = self._assert_single_item(
|
||||
tasks, name='build_full_name')
|
||||
build_greeting_task = self._assert_single_item(
|
||||
tasks, name='build_greeting')
|
||||
|
||||
# Check the first task.
|
||||
self.assertEqual(states.SUCCESS, build_full_name_task['state'])
|
||||
@ -175,12 +175,12 @@ class DataFlowTest(base.EngineTestCase):
|
||||
|
||||
self.assertEqual(3, len(tasks))
|
||||
|
||||
build_full_name_task = \
|
||||
self._assert_single_item(tasks, name='build_full_name')
|
||||
build_greeting_task = \
|
||||
self._assert_single_item(tasks, name='build_greeting')
|
||||
send_greeting_task = \
|
||||
self._assert_single_item(tasks, name='send_greeting')
|
||||
build_full_name_task = self._assert_single_item(
|
||||
tasks, name='build_full_name')
|
||||
build_greeting_task = self._assert_single_item(
|
||||
tasks, name='build_greeting')
|
||||
send_greeting_task = self._assert_single_item(
|
||||
tasks, name='send_greeting')
|
||||
|
||||
# Check the first task.
|
||||
self.assertEqual(states.SUCCESS, build_full_name_task['state'])
|
||||
@ -312,10 +312,10 @@ class DataFlowTest(base.EngineTestCase):
|
||||
|
||||
self.assertEqual(2, len(tasks))
|
||||
|
||||
build_full_name_task = \
|
||||
self._assert_single_item(tasks, name='build_full_name')
|
||||
build_greeting_task = \
|
||||
self._assert_single_item(tasks, name='build_greeting')
|
||||
build_full_name_task = self._assert_single_item(
|
||||
tasks, name='build_full_name')
|
||||
build_greeting_task = self._assert_single_item(
|
||||
tasks, name='build_greeting')
|
||||
|
||||
# Check the first task.
|
||||
self.assertEqual(states.SUCCESS, build_full_name_task['state'])
|
||||
@ -385,12 +385,12 @@ class DataFlowTest(base.EngineTestCase):
|
||||
|
||||
self.assertEqual(3, len(tasks))
|
||||
|
||||
build_full_name_task = \
|
||||
self._assert_single_item(tasks, name='build_full_name')
|
||||
build_greeting_task = \
|
||||
self._assert_single_item(tasks, name='build_greeting')
|
||||
send_greeting_task = \
|
||||
self._assert_single_item(tasks, name='send_greeting')
|
||||
build_full_name_task = self._assert_single_item(
|
||||
tasks, name='build_full_name')
|
||||
build_greeting_task = self._assert_single_item(
|
||||
tasks, name='build_greeting')
|
||||
send_greeting_task = self._assert_single_item(
|
||||
tasks, name='send_greeting')
|
||||
|
||||
# Check the first task.
|
||||
self.assertEqual(states.SUCCESS, build_full_name_task['state'])
|
||||
|
@ -70,8 +70,8 @@ def set_thread_local(var_name, val):
|
||||
if val:
|
||||
gl_storage = _get_greenlet_local_storage()
|
||||
if not gl_storage:
|
||||
gl_storage = \
|
||||
_th_loc_storage.greenlet_locals[corolocal.get_ident()] = {}
|
||||
gl_storage = _th_loc_storage.greenlet_locals[
|
||||
corolocal.get_ident()] = {}
|
||||
|
||||
gl_storage[var_name] = val
|
||||
|
||||
@ -83,11 +83,11 @@ def log_exec(logger, level=logging.DEBUG):
|
||||
|
||||
def _decorator(func):
|
||||
def _logged(*args, **kw):
|
||||
params_repr = "[args=%s, kw=%s]" % (str(args), str(kw)) \
|
||||
if len(args) > 0 or len(kw) > 0 else ""
|
||||
params_repr = ("[args=%s, kw=%s]" % (str(args), str(kw))
|
||||
if len(args) > 0 or len(kw) > 0 else "")
|
||||
|
||||
func_repr = "Called method [name=%s, doc='%s', params=%s]" % \
|
||||
(func.__name__, func.__doc__, params_repr)
|
||||
func_repr = ("Called method [name=%s, doc='%s', params=%s]" %
|
||||
(func.__name__, func.__doc__, params_repr))
|
||||
|
||||
logger.log(level, func_repr)
|
||||
|
||||
|
@ -46,8 +46,8 @@ class WorkbookSpec(base.BaseSpec):
|
||||
self._description = data.get('description')
|
||||
self._tags = data.get('tags', [])
|
||||
self._actions = self._spec_property('actions', act.ActionSpecList)
|
||||
self._workflows = \
|
||||
self._spec_property('workflows', wf.WorkflowSpecList)
|
||||
self._workflows = self._spec_property(
|
||||
'workflows', wf.WorkflowSpecList)
|
||||
self._triggers = self._spec_property('triggers', tr.TriggerSpecList)
|
||||
|
||||
def get_name(self):
|
||||
|
@ -301,8 +301,9 @@ class WorkflowHandler(object):
|
||||
self.exec_db.state = state
|
||||
self.exec_db.state_info = state_info
|
||||
else:
|
||||
msg = "Can't change workflow state [execution=%s," \
|
||||
" state=%s -> %s]" % (self.exec_db, cur_state, state)
|
||||
msg = ("Can't change workflow state "
|
||||
"[execution=%s, state=%s -> %s]" %
|
||||
(self.exec_db, cur_state, state))
|
||||
raise exc.WorkflowException(msg)
|
||||
|
||||
|
||||
|
@ -132,8 +132,8 @@ def evaluate_task_outbound_context(task_db):
|
||||
:return: Outbound task Data Flow context.
|
||||
"""
|
||||
|
||||
in_context = copy.deepcopy(dict(task_db.in_context)) \
|
||||
if task_db.in_context is not None else {}
|
||||
in_context = (copy.deepcopy(dict(task_db.in_context))
|
||||
if task_db.in_context is not None else {})
|
||||
|
||||
out_ctx = utils.merge_dicts(in_context, task_db.output)
|
||||
|
||||
|
@ -42,8 +42,8 @@ class ReverseWorkflowHandler(base.WorkflowHandler):
|
||||
task_spec = self.wf_spec.get_tasks().get(task_name)
|
||||
|
||||
if not task_spec:
|
||||
msg = 'Invalid task name [wf_spec=%s, task_name=%s]' % \
|
||||
(self.wf_spec, task_name)
|
||||
msg = 'Invalid task name [wf_spec=%s, task_name=%s]' % (
|
||||
self.wf_spec, task_name)
|
||||
raise exc.WorkflowException(msg)
|
||||
|
||||
task_specs = self._find_tasks_without_dependencies(task_spec)
|
||||
|
@ -24,8 +24,8 @@ class TaskResult(object):
|
||||
self.error = error
|
||||
|
||||
def __repr__(self):
|
||||
return 'TaskResult [data=%s, error=%s]' % \
|
||||
(repr(self.data), repr(self.error))
|
||||
return 'TaskResult [data=%s, error=%s]' % (
|
||||
repr(self.data), repr(self.error))
|
||||
|
||||
def is_error(self):
|
||||
return self.error is not None
|
||||
|
Loading…
Reference in New Issue
Block a user