# 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
                self.srv = make_wsgi_server(
                    self.host,
                    self.port,
                    app,
                    Server,
                    Handler)
                proxy.server = self.srv
                self.port = self.srv.server_port
                proxy._started.put(True)
                self.srv.serve_forever(poll_interval=0.1)

        bottle.post('/', callback=self._request_handler)

        def serve():
            bottle.run(
                host='localhost',
                port=self.port,
                quiet=True,
                server=BottleServerAdapter)
        thread = threading.Thread(target=serve)
        thread.daemon = True
        thread.start()
        return thread

    def close(self):
        self.server.shutdown()
        self.server.server_close()

    def _request_handler(self):
        request = bottle.request.body.read()

# 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

                self.srv = make_wsgi_server(
                    self.host,
                    self.port,
                    app,
                    Server,
                    Handler)
                proxy.server = self.srv
                self.port = self.srv.server_port
                proxy._started.put(True)
                self.srv.serve_forever(poll_interval=0.1)

        bottle.post('/', callback=self._request_handler)

        def serve():
            bottle.run(
                host='localhost',
                port=self.port,
                quiet=True,
                server=BottleServerAdapter)
        thread = threading.Thread(target=serve)
        thread.daemon = True
        thread.start()
        return thread

    def close(self):
        self.server.shutdown()
        self.server.server_close()

    def _request_handler(self):
        request = bottle.request.body.read()

        with current_ctx.push(self.ctx):