Esempio n. 1
0
    def test_magic_methods(self):
        pm = PyPluginManager(self.plugin_dirs, services=self.services)
	#check the python __*method*__ ;)
	self.assertEqual('plugin_test' in pm, False)
	self.assertEqual(pm['plugin_test'], None)
        pm.discover()
	self.assertEqual('plugin_test' in pm, True)
	for p in pm:
		self.assertTrue(pm[p])
    global signals
    if signal_name in signals:
        for data in signals[signal_name]:
            method = data['method']
            #Call the method
            print method(*args, **kwds)



if __name__ == '__main__':
    plugin_dirs = (os.path.abspath("pyPlugin_plugins"), )  
    services_to_plugins = ServiceCollection()
    #provide a SERVICE to the plugins
    services_to_plugins.add("connect", connect)
    mb = MessageBox('pyplugin_message_box')
    pm = PyPluginManager(plugin_dirs, services_to_plugins, message_box=mb)
    pm.discover()
    pm.load_all()
    if len(pm):
        print "Listing all the plugins:"
	print "========================"
	for p in pm:
            print "    %s - %s" % (p, pm[p].get_info())
        print "\n"
    answer = True
    print 'Valid usernames to emit signals are: (admin, pyplugin)'
    while answer:
        key = str(raw_input("Username: \n"))
        if key == 'admin':
            print ''
            print 'Inside the plugin'
Esempio n. 3
0
    def test_load_one(self):
        pm = PyPluginManager(self.plugin_dirs, services=self.services, auto_init=True)
	#check load
	pm.load('plugin_test')
	self.assertEqual(len(pm), 1)
Esempio n. 4
0
    def test_discover(self):
        pm = PyPluginManager(self.plugin_dirs, services=self.services)
	self.assertEqual(len(pm), 0)
	pm.discover()
	self.assertEqual(len(pm), 1)