Пример #1
0
 def __init__(self, factory, addr):
     self.factory = factory
     self.host = addr.host
     self.logger = logging.getLogger("Protocol")
     self.events = manager.manager()
     self.id = None
     self.pings = []
Пример #2
0
    def __init__(self):
        self.servers = {}
        self.clients = []
        self.logger = logging.getLogger("Factory")
        self.plugman = PluginManagerSingleton.get()
        self.events = manager.manager()
        self.plugman.setPluginPlaces(["plugins"])
        self.plugman.setPluginInfoExtension("plug")
        self.plugman.collectPlugins()

        self.logger.info("Loading plugins..")
        for pluginInfo in self.plugman.getAllPlugins():
            try:
                self.plugman.activatePluginByName(pluginInfo.name)
                pluginInfo.plugin_object._add_variables(pluginInfo, self)
                pluginInfo.plugin_object.setup()
            except Exception:
                self.logger.warn("Unable to load plugin: %s v%s" % (pluginInfo.name, pluginInfo.version))
                util.output_exception(self.logger, logging.WARN)
                self.plugman.deactivatePluginByName(pluginInfo.name)
            else:
                self.logger.info("Loaded plugin: %s v%s" % (pluginInfo.name, pluginInfo.version))
                event = pluginLoadedEvent(self, pluginInfo)
                self.events.runCallback("pluginLoaded", event)
        self.logger.info("Finished loading plugins.")

        event = pluginsLoadedEvent(self)
        self.events.runCallback("pluginsLoaded", event)
Пример #3
0
 def setup(self):
     self.config = conf.conf()
     if not self.config.get_mapping("echo"):
         self.config.save_mapping("echo", "echo.yml")
         self.config.save_file("echo.yml", {"enabled": True})
         self.config.reload()
     self.events = manager.manager()
     self.events.addCallback("dataReceived", self, self.onDataReceived, 10)
Пример #4
0
 def setup(self):
     self.config = conf.conf()
     if not self.config.get_mapping("hello"):
         self.config.save_mapping("hello", "hello.yml")
         self.config.save_file("hello.yml", {"message": "Hello, world!"})
         self.config.reload()
     self.events = manager.manager()
     self.events.addCallback("dataReceived", self, self.onDataReceived, 1)
     self.logger.info(self.config.get("hello")["message"])
Пример #5
0
 def setup(self):
     self.config = conf.conf()
     self.logger = logging.getLogger("Auth")
     if not self.config.get_mapping("auth"):
         self.config.save_mapping("auth", "auth.yml")
         self.config.save_file("auth.yml", {"keys": {}})
         self.config.reload()
     self.events = manager.manager()
     self.events.addCallback("dataReceived", self, self.onDataReceived, 99999)
     self.events.addCallback("protocolBuilt", self, self.onProtocolBuiltEvent, 99999)
     self.events.addCallback("clientDisconnected", self, self.onClientDisconnected, 0)
Пример #6
0
 def setup(self):
     self.config = conf.conf()
     self.logger = logging.getLogger("Players")
     self.events = manager.manager()
     self.events.addCallback("dataReceived", self, self.onDataReceived, 0)
     self.events.addCallback("protocolBuilt", self, self.onProtocolBuiltEvent, 99999)