# Path: cloudify/proxy/client.py
# class ScriptException(Exception):
#     def __init__(self, message=None, retry=False):
#         super(Exception, self).__init__(message)
#         self.retry = retry
# 
# Path: cloudify/state.py
# class NotInContext(RuntimeError):
# class CtxParameters(dict):
# class CurrentContext(threading.local):
#     def __init__(self, parameters):
#     def __getattr__(self, attr):
#     def set(self, ctx, parameters=None):
#     def get_ctx(self):
#     def get_parameters(self):
#     def _get(self, attribute):
#     def clear(self):
#     def push(self, ctx, parameters=None):
# def ctx():
# def ctx_parameters():
# def workflow_ctx():
# def workflow_parameters():


import traceback
import tempfile
import re
import collections
import json
import threading
import socket
import bottle
        import zmq
        import zmq
from Queue import Queue
from StringIO import StringIO
from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
from wsgiref.simple_server import make_server as make_wsgi_server
from cloudify.proxy.client import ScriptException
from cloudify.state import current_ctx
# Copyright (c) 2014 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.





class CtxProxy(object):

    def __init__(self, ctx, socket_url):
        self.ctx = ctx
        self.socket_url = socket_url

    def process(self, request):
        try:
            typed_request = json.loads(request)
            args = typed_request['args']
            payload = process_ctx_request(self.ctx, args)
            result_type = 'result'

# Path: cloudify/proxy/client.py
# class ScriptException(Exception):
#     def __init__(self, message=None, retry=False):
#         super(Exception, self).__init__(message)
#         self.retry = retry
# 
# Path: cloudify/state.py
# class NotInContext(RuntimeError):
# class CtxParameters(dict):
# class CurrentContext(threading.local):
#     def __init__(self, parameters):
#     def __getattr__(self, attr):
#     def set(self, ctx, parameters=None):
#     def get_ctx(self):
#     def get_parameters(self):
#     def _get(self, attribute):
#     def clear(self):
#     def push(self, ctx, parameters=None):
# def ctx():
# def ctx_parameters():
# def workflow_ctx():
# def workflow_parameters():


# Path: cloudify/proxy/server.py
import traceback
import tempfile
import re
import collections
import json
import threading
import socket
import bottle
        import zmq
        import zmq
from Queue import Queue
from StringIO import StringIO
from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
from wsgiref.simple_server import make_server as make_wsgi_server
from cloudify.proxy.client import ScriptException
from cloudify.state import current_ctx

# Copyright (c) 2014 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.





class CtxProxy(object):

    def __init__(self, ctx, socket_url):
        self.ctx = ctx
        self.socket_url = socket_url

    def process(self, request):
        try:
            typed_request = json.loads(request)
            args = typed_request['args']
            payload = process_ctx_request(self.ctx, args)
            result_type = 'result'

            if isinstance(payload, ScriptException):