# Path: kael/web_admin/exceptions.py
# OK = 10000
# class BaseError(Exception):
# class UnknownError(BaseError):
# class AuthError(BaseError):
# class InvalidTokenError(BaseError):
# class ArgumentError(BaseError):
# class MissArgumentError(ArgumentError):
# class NoFoundObjError(ArgumentError):
# class ObjExistError(ArgumentError):
# class InternalError(BaseError):
# class TimeoutError(InternalError):
# class UnsupportedError(ArgumentError):
# class WebProxyError(BaseError):
#     def __init__(self, description=None):
#     def __str__(self):
#     def __repr__(self):


import os
import pkgutil
import types
import simplejson as json
                import traceback
from datetime import date, datetime
from bson import ObjectId
from flask import Response, current_app, make_response, request, stream_with_context
from werkzeug.routing import BaseConverter
from kael.web_admin import exceptions
    return bls


class ServerSentEvent(object):
    def __init__(self, data):
        self.data = data
        self.event = None
        self.id = None
        self.desc_map = {
            self.data: "data",
            self.event: "event",
            self.id: "id"
        }

    def encode(self):
        if not self.data:
            return ""
        lines = ["%s: %s" % (v, k)
                 for k, v in self.desc_map.iteritems() if k]

        return "%s\n\n" % "\n".join(lines)


def stream_gen(f, flag=False):
    def decorator(*args, **kwargs):
        def SEE(ctx):
            for i in ctx:
                if flag:
                    data = to_json(
                        {

# Path: kael/web_admin/exceptions.py
# OK = 10000
# class BaseError(Exception):
# class UnknownError(BaseError):
# class AuthError(BaseError):
# class InvalidTokenError(BaseError):
# class ArgumentError(BaseError):
# class MissArgumentError(ArgumentError):
# class NoFoundObjError(ArgumentError):
# class ObjExistError(ArgumentError):
# class InternalError(BaseError):
# class TimeoutError(InternalError):
# class UnsupportedError(ArgumentError):
# class WebProxyError(BaseError):
#     def __init__(self, description=None):
#     def __str__(self):
#     def __repr__(self):


# Path: kael/web_admin/common.py
import os
import pkgutil
import types
import simplejson as json
                import traceback
from datetime import date, datetime
from bson import ObjectId
from flask import Response, current_app, make_response, request, stream_with_context
from werkzeug.routing import BaseConverter
from kael.web_admin import exceptions

    return bls


class ServerSentEvent(object):
    def __init__(self, data):
        self.data = data
        self.event = None
        self.id = None
        self.desc_map = {
            self.data: "data",
            self.event: "event",
            self.id: "id"
        }

    def encode(self):
        if not self.data:
            return ""
        lines = ["%s: %s" % (v, k)
                 for k, v in self.desc_map.iteritems() if k]

        return "%s\n\n" % "\n".join(lines)


def stream_gen(f, flag=False):
    def decorator(*args, **kwargs):
        def SEE(ctx):
            for i in ctx:
                if flag:
                    data = to_json(
                        {

                            'status': exceptions.OK,