import inspect import json import zmq import uuid import time from txzmq import ZmqFactory, ZmqEndpoint from txzmq import ZmqREQConnection, ZmqREPConnection from txzmq import ZmqPullConnection, ZmqPushConnection from txzmq import ZmqRequestTimeoutError from txzmq import ZmqSubConnection, ZmqPubConnection from twisted.internet import reactor from twisted.internet.defer import Deferred, maybeDeferred import observatory debug, log, warn, error, critical = observatory.get_loggers("zmq") from exception import * class ComponentExport(): def __init__(self, component): self.component = component def export(obj): obj._exported = True return obj class Export: def __init__(self, wrapped): """
# # Copyright 2014 Mimetic Markets, Inc. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # from collections import defaultdict import inspect from twisted.internet.defer import inlineCallbacks, returnValue, DeferredList import observatory debug, log, warn, error, critical = observatory.get_loggers("plugin_manager") class PluginException(Exception): pass class PluginManager: def __init__(self): self.plugins = {} self.services = defaultdict(list) self.events = defaultdict(list) def register(self, plugin, event, handler): if not callable(handler): raise PluginException("Handler %s is not callable." % handler) self.events[event].append((plugin, handler)) def unregister(self, plugin, event, handler):