示例#1
0
    def create_menubar(self):
        menubar = QMenuBar()

        file_menu = menubar.addMenu('&File')
        file_menu.addAction('&New',
                            self.new_script).setShortcut(QKeySequence.New)
        file_menu.addAction('Save As...', self.save_script_as).setShortcut(
            QKeySequence.SaveAs)
        file_menu.addAction('&Open',
                            self.open_script).setShortcut(QKeySequence.Open)
        file_menu.addAction('&Save',
                            self.save_script).setShortcut(QKeySequence.Save)
        file_menu.addAction('&Quit', self.close)

        # Script actions
        script_menu = menubar.addMenu('&Script')
        script_menu.addAction('&Evaluate',
                              self.plugin_handler.evaluate_current_script)
        script_menu.addAction('&Copy Hex', self.script_editor.copy_hex)

        # Settings and tool toggling
        tools_menu = menubar.addMenu('&Tools')
        tools_menu.addAction('&Settings', self.show_settings_dialog)
        tools_menu.addAction('&Plugin Manager',
                             lambda: PluginManager(self).exec_())
        tools_menu.addSeparator()
        self.plugin_handler.create_menu(tools_menu)

        help_menu = menubar.addMenu('&Help')
        help_menu.addAction('&About', self.do_about)
        help_menu.addAction('&Quick Tips', self.do_quick_tips)

        self.setMenuBar(menubar)
示例#2
0
def startup(config_path=DEFAULT_SETTINGS_FILE):
    #init logging
    config = ConfigParser.ConfigParser()
    config.read(config_path)
    setup_logging(config)

    #load the config file and start the listener, daemon
    logging.debug('reading setting from: %s' % config_path)

    #Load the plugin manager to get a handle to the plugins.
    _plugin_manager = PluginManager(config)
    locator = _plugin_manager.get_resource_locator()
    datastore = _plugin_manager.get_datastore()
    driver = _plugin_manager.get_driver()

    _registrar = Registrar(datastore, driver)

    #should the listener be started?
    start_server = config.getboolean('DEFAULT', 'start_server')
    if start_server:
        server.set_registrar(registrar)
        Thread.start(server.start())

    #start looking for backends and updating the driver
    #THIS CALL WILL NOT RETURN
    daemon.start(_registrar, locator, config)
示例#3
0
def main():
    # Read config
    config = ConfigParser()
    config.readfp(open(os.path.dirname(os.path.abspath(__file__)) + "/smtpd.cfg.default"))
    config.read(["smtpd.cfg",])

    # Configure the logger
    logging.basicConfig(level=getattr(logging, config["logging"]["log_level"].upper()),
            format='%(levelname)s: %(asctime)s %(message)s',
            datefmt='%m/%d/%Y %I:%M:%S %p')

    loop = asyncio.get_event_loop()

    # Init plugin manager
    plugin_manager = PluginManager(loop)

    logger.info("Starting smtpd on {}:{}".format(config["smtpd"]["host"], config["smtpd"]["port"]))
    cont = CustomIdentController(
            MailHandler(loop, config, plugin_manager),
            loop=loop,
            ident_hostname=config["smtpd"]["hostname"],
            ident=config["smtpd"]["ident"],
            hostname=config["smtpd"]["host"],
            port=config["smtpd"]["port"])
    cont.start()

    # Ugly but whatever, wait until the controller thread finishes (wtf why do they start a thread)
    threads = threading.enumerate()
    for thread in threads:
        if not threading.current_thread() == thread:
            thread.join()

    plugin_manager.stop_plugins()
示例#4
0
文件: mee6.py 项目: JerryHobby/mee6
 def __init__(self, *args, **kwargs):
     discord.Client.__init__(self, *args, **kwargs)
     self.redis_url = kwargs.get('redis_url')
     self.db = Db(self.redis_url)
     self.plugin_manager = PluginManager(self)
     self.plugin_manager.load_all()
     self.last_messages = []
示例#5
0
def get_input_plugins_config():
    """Append all configs of the input plugins."""
    config = ""
    plugin_manager = PluginManager(PLUGINS_FILE)
    input_plugins = plugin_manager.get_input_plugins()
    for app, conf in input_plugins.items():
        config += conf + "\n\n\n"
    return config
示例#6
0
    def test_map_plugin_packets(self, mock_config, mock_path, mock_sys):
        mock_plugin = Mock()
        mock_plugin.name = 'Test'
        mock_plugin.overridden_packets = {
            1: {
                'on': 'add me on 1',
                'after': 'add me after 1'
            }
        }
        mock_plugin2 = Mock()
        mock_plugin2.name = 'Test2'
        mock_plugin2.overridden_packets = {
            2: {
                'on': 'add me on 2'
            },
            3: {
                'after': 'add me after 2'
            }
        }

        pm = PluginManager(Mock())
        pm.map_plugin_packets(mock_plugin)

        self.assertDictEqual(
            pm.packets, {
                1: {
                    'on': {
                        'Test': (mock_plugin, 'add me on 1')
                    },
                    'after': {
                        'Test': (mock_plugin, 'add me after 1')
                    }
                }
            })

        pm.map_plugin_packets(mock_plugin2)
        self.assertDictEqual(
            pm.packets, {
                1: {
                    'on': {
                        'Test': (mock_plugin, 'add me on 1')
                    },
                    'after': {
                        'Test': (mock_plugin, 'add me after 1')
                    }
                },
                2: {
                    'on': {
                        'Test2': (mock_plugin2, 'add me on 2')
                    }
                },
                3: {
                    'after': {
                        'Test2': (mock_plugin2, 'add me after 2')
                    }
                }
            })
示例#7
0
 def __init__(self):
     self.plugin_path = path / 'tests' / 'test_plugins'
     self.good_plugin = self.plugin_path / 'test_plugin_2.py'
     self.good_plugin_package = self.plugin_path / 'test_plugin_package'
     self.bad_plugin = self.plugin_path / 'bad_plugin'
     self.bad_path = self.plugin_path / 'bad_path.py'
     self.dependent_plugins = self.plugin_path / "dependent_plugins"
     self.plugin_manager = PluginManager(None)
     self.loop = None
示例#8
0
def get_tags_config():
    """Returns a list of all the tags (applications)."""
    plugin_manager = PluginManager(PLUGINS_FILE)
    tags = plugin_manager.get_tags()
    tags_config = ""
    for tag in tags:
        line = "    {} = '{}_cpu'\n".format(tag, tag)
        tags_config += line
    return tags_config
示例#9
0
 def __init__(self, context=None, completekey='tab', stdin=sys.stdin, stdout=sys.stdout, logger=None):
     cmd.Cmd.__init__(self, completekey, stdin, stdout)
     self.plugin_mgr = PluginManager()
     self.ctx = context
     self.use_rawinput = 1
     self.ioqueue = []
     self.stdout = OutputWrapper(stdout, logger=logger)
     self.stdin = InputWrapper(stdin, logger=logger)
     self.stderr = OutputWrapper(sys.stderr, level=logging.ERROR, logger=logger)
示例#10
0
文件: main.py 项目: erick-dsnk/Jarvis
def build_plugin_manager():
    directories = ["jarviscli/plugins", "custom"]
    directories = _rel_path_fix(directories)

    plugin_manager = PluginManager()

    for directory in directories:
        plugin_manager.add_directory(directory)
    return plugin_manager
示例#11
0
    def _plugin_manager_default(self):
        """ Trait initializer. """

        # Do the import here to emphasize the fact that this is just the
        # default implementation and that the application developer is free
        # to override it!
        from plugin_manager import PluginManager

        return PluginManager(application=self)
示例#12
0
    def __init__(self, config):
        self.terminated = False  # Flag used to stop the service
        self.config = config

        # Create plugin instances and add them to manager so that they get control periodically
        # Note: plugins should be derived from class Plugin and implement update() function
        self.pluginManager = PluginManager()
        self.udpServer = UDPServer(config.scpHost, config.scpPort,
                                   self.onRequestReceived)
        self.pluginManager.add(self.udpServer)
示例#13
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.plugin_manager = PluginManager(self)
     self.plugin_manager.load_all()
     self.last_messages = []
     self.__name__ = APP_NAME
     self.__version__ = APP_VERSION
     self.__author__ = APP_AUTHOR
     self.__copyright__ = "Copyright (c){} {}".format(
         '2016-2020', self.__author__)
示例#14
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.redis_url = kwargs.get('redis_url')
     self.mongo_url = kwargs.get('mongo_url')
     self.dd_agent_url = kwargs.get('dd_agent_url')
     self.db = Db(self.redis_url, self.mongo_url, self.loop)
     self.plugin_manager = PluginManager(self)
     self.plugin_manager.load_all()
     self.last_messages = []
     self.stats = DDAgent(self.dd_agent_url)
示例#15
0
    def __init__(self, prefix, token, cwd):
        Client.__init__(self)
        self.prefix = prefix
        self.token = token
        self.cwd = cwd

        self.plugin_manager = PluginManager(self, '%s/plugins' % self.cwd)
        self.plugin_manager.load_plugins()

        user_agent = get_resource(self.cwd, 'user_agent')
        self.client_session = ClientSession(headers={'User-Agent': user_agent})
示例#16
0
    def test_installed_plugins(self, mock_config, mock_path, mock_sys):
        mock_child = Mock(path='test child')
        mock_child.globChildren.return_value = [
            Mock(basename=lambda: 'plugin'),
            Mock(basename=lambda: None),
            Mock(basename=lambda: 'core')
        ]
        mock_path.child.return_value = mock_child

        pm = PluginManager(Mock())
        result = pm.installed_plugins()

        self.assertListEqual(result, ['plugin'])
示例#17
0
    def test_deactivate_plugins(self, mock_config, mock_path, mock_sys,
                                mock_reversed, mock_de_map):
        mock_reversed.side_effect = reversed
        pm = PluginManager(Mock())
        pm.load_order = [1]

        pm.plugins = {
            1: Mock(name='1'),
        }
        pm.deactivate_plugins()

        mock_reversed.assert_called_with([1])
        self.assertTrue(pm.plugins[1].deactivate.called)
        mock_de_map.assert_called_with(pm.plugins[1])
示例#18
0
 def __init__(self):
     """
     Initializes persistent objects and prepares a list of connected
     protocols.
     """
     self.config = ConfigurationManager()
     self.protocol.factory = self
     self.protocols = {}
     try:
         self.plugin_manager = PluginManager(factory=self)
     except FatalPluginError:
         logger.critical("Shutting Down.")
         sys.exit()
     self.reaper = LoopingCall(self.reap_dead_protocols)
     self.reaper.start(self.config.reap_time)
示例#19
0
文件: mee6.py 项目: voarsh2/mee6
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.redis_url = kwargs.get('redis_url')
        self.mongo_url = kwargs.get('mongo_url')
        self.dd_agent_url = kwargs.get('dd_agent_url')
        self.sentry_dsn = kwargs.get('sentry_dsn')
        self.db = Db(self.redis_url, self.mongo_url, self.loop)
        self.plugin_manager = PluginManager(self)
        self.plugin_manager.load_all()
        self.last_messages = []
        self.stats = DDAgent(self.dd_agent_url)
        self.voice_sessions_ids = dict()

        if self.shard_id is not None:
            self.shard = [self.shard_id, self.shard_count]
        else:
            self.shard = [0, 1]
示例#20
0
def main():
    cfg = SafeConfigParser()
    cfg.read('mysql_db.cfg')
    plugin_manager = PluginManager()
    connection = MySQLdb.connect(user=cfg.get('main', 'user'),
                                 passwd=cfg.get('main', 'passwd'),
                                 host=cfg.get('main', 'host'))
    env_vars = plugin_manager.call_method('generate',
                                          keywords=['provider'],
                                          args={'connection': connection})
    plugin_manager.call_method('process',
                               keywords=['consumer'],
                               args={
                                   'connection': connection,
                                   'env_vars': env_vars
                               })
    plugin_manager.call_method('report')
示例#21
0
 def __init__(self, plugin_package="jsk_teleop_joy"):
     self.state = self.STATE_INITIALIZATION
     self.pre_status = None
     self.history = StatusHistory(max_length=10)
     self.menu_pub = rospy.Publisher("/overlay_menu", OverlayMenu)
     self.controller_type = rospy.get_param('~controller_type', 'auto')
     self.plugins = rospy.get_param('~plugins', {})
     self.current_plugin_index = 0
     self.selecting_plugin_index = 0
     #you can specify the limit of the rate via ~diagnostic_period
     self.diagnostic_updater = DiagnosticUpdater()
     self.diagnostic_updater.setHardwareID("teleop_manager")
     self.diagnostic_updater.add("State", self.stateDiagnostic)
     self.diagnostic_updater.add("Plugin Status",
                                 self.pluginStatusDiagnostic)
     #self.diagnostic_updater.add("Joy Input", self.joyInputDiagnostic)
     self.diagnostic_updater.update()
     if self.controller_type == 'xbox':
         self.JoyStatus = XBoxStatus
     elif self.controller_type == 'ps3':
         self.JoyStatus = PS3Status
     elif self.controller_type == 'ps3wired':
         self.JoyStatus = PS3WiredStatus
     elif self.controller_type == 'ipega':
         self.JoyStatus = IpegaStatus
     elif self.controller_type == 'auto':
         s = rospy.Subscriber('/joy', Joy, autoJoyDetect)
         self.state = self.STATE_WAIT_FOR_JOY
         error_message_published = False
         r = rospy.Rate(1)
         while not rospy.is_shutdown():
             self.diagnostic_updater.update()
             if AUTO_DETECTED_CLASS == "UNKNOWN":
                 if not error_message_published:
                     rospy.logfatal("unknown joy type")
                     error_message_published = True
                 r.sleep()
             elif AUTO_DETECTED_CLASS:
                 self.JoyStatus = AUTO_DETECTED_CLASS
                 s.unregister()
                 break
             else:
                 r.sleep()
     self.diagnostic_updater.update()
     self.plugin_manager = PluginManager(plugin_package)
     self.loadPlugins()
示例#22
0
 def __init__(self):
     try:
         self.protocols = []
         self.configuration_manager = ConfigurationManager()
         self.configuration_manager.load_config(path / 'config' /
                                                'config.json',
                                                default=True)
         self.plugin_manager = PluginManager(self.configuration_manager)
         self.plugin_manager.load_from_path(
             path / self.configuration_manager.config.plugin_path)
         self.plugin_manager.resolve_dependencies()
         self.plugin_manager.activate_all()
         asyncio.Task(self.plugin_manager.get_overrides())
     except Exception as e:
         print("Exception encountered during server startup.")
         print(e)
         loop.stop()
         sys.exit()
示例#23
0
def main():
    # Handle command line inputs
    p = argparse.ArgumentParser(
        description=
        "Reads logs in the Apache Combined Log Format and the Common Log Format."
    )
    p.add_argument('-f',
                   help='Tail the log file.',
                   dest='tail',
                   action='store_true')
    p.add_argument('-l', help='Path to logfile.', dest='file')
    p.add_argument('-v',
                   help='Enable verbose.',
                   dest='verbose',
                   action='store_true')
    p.add_argument('-p',
                   help='Arguments for the plugins. Splitted with spaces',
                   dest='plugs',
                   nargs='+')
    p.add_argument('-s',
                   help='Silent. Superseedes -v and disables logging.',
                   dest='silent',
                   action='store_true')
    p.set_defaults(verbose=False,
                   silent=False,
                   file='/tmp/access.log',
                   tail=False,
                   plugs=[])

    args = p.parse_args()

    logger_to_stdout()

    if args.verbose:
        set_verbose()

    if args.silent:
        set_silent()

    manager = PluginManager()
    manager.load_plugins(args.plugs)

    parser.tail(args.file, manager, tail=args.tail)
示例#24
0
    def __init__(self):
        try:
            self.connections = []
            self.configuration_manager = ConfigurationManager()
            self.configuration_manager.load_config(path / 'config' /
                                                   'config.json',
                                                   default=True)
            self.plugin_manager = PluginManager(self.configuration_manager,
                                                factory=self)
            self.plugin_manager.load_from_path(
                path / self.configuration_manager.config.plugin_path)
            self.plugin_manager.resolve_dependencies()
            self.plugin_manager.activate_all()
            asyncio.ensure_future(self.plugin_manager.get_overrides())
        except Exception as err:
            logger.exception("Error during server startup.", exc_info=True)

            loop.stop()
            sys.exit()
示例#25
0
 def __init__(self):
     """
     Initializes persistent objects and prepares a list of connected
     protocols.
     """
     self.config = ConfigurationManager()
     self.protocol.factory = self
     self.protocols = {}
     self.plugin_manager = PluginManager(factory=self)
     try:
         self.plugin_manager.prepare()
     except FatalPluginError:
         logger.critical('Shutting Down.')
         sys.exit()
     self.reaper = LoopingCall(self.reap_dead_protocols)
     self.reaper.start(self.config.reap_time)
     logger.debug(
         'Factory created, endpoint of port %d', self.config.bind_port
     )
示例#26
0
	def __init__(self, config):
		"""
		Sets up initial bot data and the PluginManager which loads inital plugins.
		...

		Parameters
		----------
		config: Config
			Configuration object containing data found within the bot's configuration file.
		"""

		self.logger = logging.getLogger('bot_log')
		self.directory = config.bot_dir
		self.base_url = "https://api.telegram.org/bot"+config.token+"/"
		self.sleep_interval = config.sleep_interval
		self.username = json.loads(requests.get(self.base_url + "getMe").text)["result"]["username"]
		self.plugin_manager = PluginManager(config, self)

		print(self.plugin_manager.list_commands())
		print(self.plugin_manager.list_listeners())
示例#27
0
    def test_de_map_plugin_packets(self, mock_config, mock_path, mock_sys):
        mock_plugin = Mock()
        mock_plugin.name = 'Test'

        pm = PluginManager(Mock())
        pm.packets = {
            1: {
                'on': {
                    'Test': 'remove me'
                },
                'after': {
                    'Test2': 'test'
                }
            },
            2: {
                'on': {
                    'Test': 'remove me',
                    'Test3': 'test'
                },
                'after': {
                    'Test': 'remove me'
                },
            }
        }
        pm.de_map_plugin_packets(mock_plugin)
        self.assertDictEqual(
            pm.packets, {
                1: {
                    'on': {},
                    'after': {
                        'Test2': 'test'
                    }
                },
                2: {
                    'on': {
                        'Test3': 'test'
                    },
                    'after': {},
                }
            })
示例#28
0
    def test_prepare(self, mock_config, mock_path, mock_sys,
                     mock_load_plugins):
        mock_factory = Mock()

        mock_path.child.return_value = Mock(path='test child')
        mock_config.return_value = Mock(
            plugin_path='test path',
            config={'initial_plugins': 'test initial plugins'})

        pm = PluginManager(mock_factory)
        pm.prepare()

        mock_path.child.assert_called_with('test path')
        mock_sys.path.append.assert_called_with('test child')
        self.assertEqual(mock_load_plugins.call_count, 2)
        mock_load_plugins.assert_has_calls([
            call([
                'core.admin_commands_plugin', 'core.colored_names',
                'core.command_plugin', 'core.player_manager_plugin',
                'core.starbound_config_manager'
            ]),
            call('test initial plugins')
        ])
示例#29
0
def test():
    plugin_manager = PluginManager()
    # print(plugin_manager.PLUGINS)
    # processed = plugin_manager.after_setup(text="**foo bar**", plugins=('plugin1', ))
    # print('--------')
    plugin_manager.after_setup(text="--foo bar--")
示例#30
0
 def loadPlugins(self):
     self.pluginManager = PluginManager(self)