Example #1
0
    def __init__(self):
        import pluginmanager.module_manager
        self._backend = pluginmanager.PluginInterface()

        # patch to ignore import exception
        _load_source = pluginmanager.module_manager.load_source

        def patched_load_source(*args):
            try:
                return _load_source(*args)
            except ImportError as e:
                print(e)
            import sys
            return sys

        pluginmanager.module_manager.load_source = patched_load_source

        self._plugin_dependency = PluginDependency()

        self._cache = None
        self._plugins_loaded = 0
        self._cache_disabled = []

        # blacklist files
        def __ends_with_py(s):
            return [x for x in s if x.endswith(".py")]

        self._backend.set_file_filters(__ends_with_py)
        self._backend.add_blacklisted_directories("jarviscli/packages/aiml")
        self._backend.add_blacklisted_directories("jarviscli/packages/memory")
Example #2
0
    def __init__(self, configuration, bot_name="vex"):
        # get the settings path and then load the settings from file
        settings_path = configuration.get('settings_path')
        settings = configuration.load_settings(settings_path)
        self.messaging = Messaging(settings)

        # create the plugin manager
        self.plugin_manager = pluginmanager.PluginInterface()
        # add the entry points of interest
        self.plugin_manager.add_entry_points(
            ('vexbot.plugins', 'vexbot.adapters'))

        # create the subprocess manager and add in the plugins
        self.subprocess_manager = SubprocessManager()
        self._update_plugins(settings, self.subprocess_manager,
                             self.plugin_manager)

        subprocesses_to_start = settings.get('startup_adapters', [])
        subprocesses_to_start.extend(settings.get('startup_plugins', []))
        self.subprocess_manager.start(subprocesses_to_start)

        self.name = bot_name
        self._logger = logging.getLogger(__name__)
        self.command_manager = BotCommandManager(robot=self)
        try:
            import setproctitle
            setproctitle.setproctitle(bot_name)
        except ImportError:
            pass
Example #3
0
def main():
    # create the Application
    app = QtWidgets.QApplication(sys.argv)

    # create the event loop and set it in asyncio
    event_loop = QEventLoop(app)
    asyncio.set_event_loop(event_loop)

    # Create the Gui
    main_window = MainWindow()
    settings_data = main_window.settings_model.root
    # Need 3 bits of information from settings. ip addresses, display missing,
    # and general settings

    # Create the recving messaging interface
    messager = ZmqMessaging()
    messager.message_signal.connect(main_window.chat_slot)
    messager.connected_signal.connect(main_window.status_bar.set_widget_status)

    # gather the plugins
    module_manager = pluginmanager.PluginInterface()
    module_manager.set_entry_points('chatimusmaximus.communication_protocols')
    modules = module_manager.collect_entry_point_plugins()

    # need to have the modules in a dict, so get the name and put in dict
    module_dict = {
        module.__name__.split('.')[-1]: module
        for module in modules
    }

    services, addresses = create_services_from_settings(
        settings_data, module_dict)

    atexit.register(_destroy_services, services)

    messager.subscribe_to_publishers(settings_data['sockets_to_connect_to'])
    # show me the money!
    main_window.show()

    # let everything asyncorous run
    try:
        event_loop.run_forever()
    # catch ctrl-C event to allow for graceful closing
    except KeyboardInterrupt:
        pass
    # tell Qt we're going out
    app.deleteLater()
    # close the event loop
    event_loop.close()
    # close the subprocesses
    for service in services:
        service.deactivate()
    # exit
    sys.exit()
Example #4
0
    def __init__(self):
        self._backend = pluginmanager.PluginInterface()
        self._plugin_dependency = PluginDependency()

        self._cache_clean = False
        self._cache_plugins = {}

        # blacklist files
        def __ends_with_py(s):
            return [x for x in s if x.endswith(".py")]
        self._backend.set_file_filters(__ends_with_py)
        self._backend.add_blacklisted_directories("jarviscli/packages/aiml")
        self._backend.add_blacklisted_directories("jarviscli/packages/memory")
Example #5
0
def main(*args, **kwargs):
    """
    kwargs:
        text_address
        result_address
        context
    """
    plugin_manager = pluginmanager.PluginInterface()
    plugin_manager.set_entry_points('languageprocessing.analyzers')
    analyzers = plugin_manager.collect_entry_point_plugins()
    invoked_analyzers = [a() for a in analyzers]

    messager = Messaging(kwargs['text_address'],
                         kwargs['result_address'],
                         context=None,
                         analyzers=invoked_analyzers)

    messager.run()
Example #6
0
 def setUp(self):
     self.interface = pluginmanager.PluginInterface()
Example #7
0
def main():
    # create the Application
    app = QtWidgets.QApplication(sys.argv)

    # create the event loop and set it in asyncio
    event_loop = QEventLoop(app)
    asyncio.set_event_loop(event_loop)

    # Create the Gui
    main_window = MainWindow()
    settings_data = main_window.settings_model.root

    # Create the recving messaging interface
    messager = ZmqMessaging()
    cmd_line_address = settings_data['display']['address']
    if cmd_line_address:
        messager.publish_to_address(cmd_line_address)

    messager.message_signal.connect(main_window.chat_slot)
    messager.connected_signal.connect(main_window.status_bar.set_widget_status)
    clear = main_window.central_widget.message_area.clear
    messager.clear_signal.connect(clear)
    main_window.command_line_signal.connect(messager.publish_message)

    sockets = settings_data['sockets_to_connect_to']
    cmd_line_address = settings_data['display']['address']

    for socket in sockets:
        if socket:
            try:
                messager.subscribe_to_publisher(socket)
            except ZMQError:
                # TODO: change to a logging command
                s = 'socket address to connect to {} is throwing errors!'
                print(s.format(socket))

    try:
        if cmd_line_address:
            messager.publish_to_address(cmd_line_address)
    except ZMQError:
        s = 'command line address to connect to {} is throwing errors!'
        print(s.format(cmd_line_address))

    plugin_manager = pluginmanager.PluginInterface()
    plugin_manager.set_entry_points('chatimusmaximus.gui')
    # plugins, names
    plugins, _ = plugin_manager.collect_entry_point_plugins()
    for plug in plugins:
        plug(main_window, messager)

    # show me the money!
    main_window.show()

    # let everything asyncorous run
    try:
        event_loop.run_forever()
    # catch ctrl-C event to allow for graceful closing
    except KeyboardInterrupt:
        pass
    # tell Qt we're going out
    app.deleteLater()
    # close the event loop
    event_loop.close()
    # exit
    sys.exit()