예제 #1
0
 def get_instantiated_plugin(self, plugin):
     if self.instantiated_plugins.has_key(plugin):
         return self.instantiated_plugins[plugin]
     else:
         debug('Instantiate %s from %s' % (plugin, plugin.__module__), 1)
         self.instantiated_plugins[plugin] = plugin()
         return self.instantiated_plugins[plugin]
예제 #2
0
 def get_instantiated_plugin(self, plugin):
     if self.instantiated_plugins.has_key(plugin):
         return self.instantiated_plugins[plugin]
     else:
         debug("Instantiate %s from %s" % (plugin, plugin.__module__), 1)
         self.instantiated_plugins[plugin] = plugin()
         return self.instantiated_plugins[plugin]
예제 #3
0
    def deactivate_plugin_set (self, plugin_set):
        # Deactivate any plugin sets that depend upon us...
        for ps in self.check_if_depended_upon(plugin_set):
            self.deactivate_plugin_set(ps)
        if plugin_set.module in self.active_plugin_sets:
            self.active_plugin_sets.remove(plugin_set.module)
        else:
            print 'Odd',plugin_set.module,'is not listed as active.'
        if plugin_set.get_module():
            for plugin in plugin_set.plugins:
                for klass in self.pluggables_by_class.keys():
                    if issubclass(plugin,klass):
                        for pluggable in self.pluggables_by_class[klass]:
                            plugin().deactivate(pluggable)

                if self.instantiated_plugins.has_key(plugin):
                    self.instantiated_plugins[plugin].remove()
                self.active_plugins.remove(plugin)
예제 #4
0
def do_create_session(key, name):
 if (not authorized_for(request, "api")):
  abort(401, "Unauthorized request")

 session = gen_session_key();
 while (session in sessions):
  session = gen_session_key()
 sessions[session] = { "name" : name, "configuration" : "", "plugin" : plugin(), "owner" : request.headers.get('Authorization') }
 return { "session" : session, "Message" : "Created new session named '%s'" % name }
예제 #5
0
def LoadPlugins(active_plugins):
    logging.info("Load plugins: %s" % active_plugins)
    plugin_dir = "%s/plugins" % os.getcwd()
    plugin_list = get_plugins(plugin_dir)
    init_plugin_system({'plugin_path': plugin_dir, 'plugins': plugin_list})
    plugins = find_plugins()
    pluggo = {}
    for plugin in plugins:
        if not pluggo.has_key(plugin.__name__) and not options.test and plugin.__name__ in active_plugins:
            p = plugin()
            logging.info("Enabling plugin: %s version: %s by: %s" % (plugin.__name__, p.version(), p.author()))
            p.start()
        pluggo[plugin.__name__] = 1
예제 #6
0
def do_create_session(key, name):
    if (not authorized_for(request, "api")):
        abort(401, "Unauthorized request")

    session = gen_session_key()
    while (session in sessions):
        session = gen_session_key()
    sessions[session] = {
        "name": name,
        "configuration": "",
        "plugin": plugin(),
        "owner": request.headers.get('Authorization')
    }
    return {
        "session": session,
        "Message": "Created new session named '%s'" % name
    }
예제 #7
0
파일: cpu.py 프로젝트: GheRivero/dconnect
from plugin import *

import os

class plugin (Plugin):

    PLUGIN_VERSION = "0.1"
    PLUGIN_NAME    = "load"

    def cpu_load(self):
        return os.getloadavg()

    def cpu_load_1(self):
        return "%5.2f" % os.getloadavg()[0]

    def cpu_load_5(self):
        return "%5.2f" % os.getloadavg()[1]

    def cpu_load_15(self):
        return "%5.2f" % os.getloadavg()[2]

    def fill_data(self,data=None):
        load_1, load_5, load_15 = self.cpu_load()
        self.data = [load_1, load_5, load_15]
        

if __name__ == "__main__":
    a = plugin()
    print a.get_data()