Example #1
0
def scan_for_plugins():
    """Look through plugin directory for any directory with a file named
    "bpplugin.json". Fill in an plugin object, and pass to _run_count_plugin to
    handle lifetime.

    """
    for i in os.listdir(config.get_dir("plugin")):
        plugin_file = os.path.join(config.get_dir("plugin"), i,
                                   Plugin.PLUGIN_INFO_FILE)
        if not os.path.exists(plugin_file):
            continue
        info = None
        try:
            with open(plugin_file) as pfile:
                info = json.load(pfile)
        except ValueError:
            logging.warning("JSON configuration not valid for plugin %s!", i)
            continue
        if not set(Plugin.PLUGIN_REQUIRED_KEYS).issubset(set(info.keys())):
            raise PluginException("Invalid Plugin")
        if info["name"] in _plugins.keys():
            raise PluginException("Plugin Collision! Two plugins named " +
                                  info["name"])
        greenlet.spawn_gevent_func("run_count_plugin: %s" % info["name"],
                                   "plugin", _run_count_plugin, Plugin(info, i))
Example #2
0
def scan_for_plugins():
    """Look through plugin directory for any directory with a file named
    "bpplugin.json". Fill in an plugin object, and pass to _run_count_plugin to
    handle lifetime.

    """
    for i in os.listdir(config.get_dir("plugin")):
        plugin_file = os.path.join(config.get_dir("plugin"), i,
                                   Plugin.PLUGIN_INFO_FILE)
        if not os.path.exists(plugin_file):
            continue
        info = None
        try:
            with open(plugin_file) as pfile:
                info = json.load(pfile)
        except ValueError:
            logging.warning("JSON configuration not valid for plugin %s!", i)
            continue
        if not set(Plugin.PLUGIN_REQUIRED_KEYS).issubset(set(info.keys())):
            raise PluginException("Invalid Plugin")
        if info["name"] in _plugins.keys():
            raise PluginException("Plugin Collision! Two plugins named " +
                                  info["name"])
        greenlet.spawn_gevent_func("run_count_plugin: %s" % info["name"],
                                   "plugin", _run_count_plugin,
                                   Plugin(info, i))
Example #3
0
 def __init__(self, info, plugin_dir):
     self.plugin_path = os.path.join(config.get_dir("plugin"), plugin_dir)
     self.executable_path = os.path.join(config.get_dir("plugin"),
                                         plugin_dir, info["executable"])
     if not os.path.exists(self.executable_path):
         raise PluginException("Cannot find plugin executable: " +
                               self.executable_path)
     self.name = info["name"]
     self.version = info["version"]
     self.messages = info["messages"]
Example #4
0
 def __init__(self, info, plugin_dir):
     self.plugin_path = os.path.join(config.get_dir("plugin"), plugin_dir)
     self.executable_path = os.path.join(config.get_dir("plugin"),
                                         plugin_dir, info["executable"])
     if not os.path.exists(self.executable_path):
         raise PluginException("Cannot find plugin executable: " +
                               self.executable_path)
     self.name = info["name"]
     self.version = info["version"]
     self.messages = info["messages"]
Example #5
0
    def setUp(self):
        reload(config)
        reload(plugin)
        reload(server)
        reload(utils)
        self.tmpdir = tempfile.mkdtemp(prefix="fetest-")
        with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
            config.init()
        self.plugin_dest = os.path.join(config.get_dir("plugin"), "test-plugin")
        self.server_loop_trigger = gevent.event.Event()
        self.copyPlugin()
        plugin.scan_for_plugins()

        def server_loop():
            server.init()
            utils.spawn_gevent_func("main socket loop", "main", server.msg_loop)
            gevent.sleep()
            self.server_loop_trigger.wait()
            server.shutdown()
        self.server_greenlet = gevent.spawn(server_loop)

        # Start a new socket
        self.test_socket = ClaimFlowTests.ClaimFlowTestSocket(config.get_value("server_address"))
        # Attach to router
        self.test_socket_greenlet = gevent.spawn(self.test_socket.run)
Example #6
0
    def setUp(self):
        reload(config)
        reload(plugin)
        reload(server)
        reload(utils)
        self.tmpdir = tempfile.mkdtemp(prefix="fetest-")
        with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
            config.init()
        self.plugin_dest = os.path.join(config.get_dir("plugin"), "test-plugin")
        self.server_loop_trigger = gevent.event.Event()

        def server_loop():
            server.init()
            utils.spawn_gevent_func("main socket loop", "main", server.msg_loop)
            gevent.sleep()
            self.server_loop_trigger.wait()
            server.shutdown()
        self.server_greenlet = gevent.spawn(server_loop)