Beispiel #1
0

if len(sys.argv) == 3:
    port = int(sys.argv[1])
    plugin_path = sys.argv[2]
else:
    raise Exception("Usage: %s path_to_plugin_dir"%sys.argv[0])


def debug( message ):
	print message 


tm = TaskManager()
pm = PluginManager()
pm.load_plugins(plugin_path)

class PluginTCPHandler(SocketServer.StreamRequestHandler):
    def handle(self):
        processor_dict = {"start": self.command_start, "status": self.command_status}
        data = self.rfile.readline()
        
        debug(">"+data)
        
        try:
            command = json.loads(data)
            
            command_name = command.get("command", "")
            command_callable = processor_dict.get(command_name, self.command_not_found)
            
            result = command_callable(command)
Beispiel #2
0
def load_plugins_from_cfg(gctx):
    pluginmanager = PluginManager(gctx)
    gctx['pluginmanager'] = pluginmanager
    pluginmanager.load_plugins()
    gctx['hdl'] += [Handler(handle, callback) for handle, callback in pluginmanager.get_handlers()]