# Path: cloudify/dispatch.py
# @task
# def dispatch(__cloudify_context, *args, **kwargs):
#     dispatch_type = __cloudify_context['type']
#     dispatch_handler_cls = TASK_HANDLERS.get(dispatch_type)
#     if not dispatch_handler_cls:
#         raise exceptions.NonRecoverableError('No handler for task type: {0}'
#                                              .format(dispatch_type))
#     handler = dispatch_handler_cls(cloudify_context=__cloudify_context,
#                                    args=args,
#                                    kwargs=kwargs)
#     return handler.handle_or_dispatch_to_subprocess_if_remote()


from cloudify import dispatch
########
# Copyright (c) 2015 GigaSpaces Technologies Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.




def run(fn, *args, **kwargs):
    cloudify_context = kwargs.get('__cloudify_context', {})
    cloudify_context.update({
        'type': 'operation',
        'task_name': '{0}.{1}'.format(fn.__module__, fn.__name__)
    })
    kwargs.pop('__cloudify_context', None)

# Path: cloudify/dispatch.py
# @task
# def dispatch(__cloudify_context, *args, **kwargs):
#     dispatch_type = __cloudify_context['type']
#     dispatch_handler_cls = TASK_HANDLERS.get(dispatch_type)
#     if not dispatch_handler_cls:
#         raise exceptions.NonRecoverableError('No handler for task type: {0}'
#                                              .format(dispatch_type))
#     handler = dispatch_handler_cls(cloudify_context=__cloudify_context,
#                                    args=args,
#                                    kwargs=kwargs)
#     return handler.handle_or_dispatch_to_subprocess_if_remote()


# Path: cloudify/test_utils/dispatch_helper.py
from cloudify import dispatch

########
# Copyright (c) 2015 GigaSpaces Technologies Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.




def run(fn, *args, **kwargs):
    cloudify_context = kwargs.get('__cloudify_context', {})
    cloudify_context.update({
        'type': 'operation',
        'task_name': '{0}.{1}'.format(fn.__module__, fn.__name__)
    })
    kwargs.pop('__cloudify_context', None)

    return dispatch.dispatch(cloudify_context, *args, **kwargs)