コード例 #1
0
ファイル: reflect.py プロジェクト: AmirKhooj/VTK
def getcurrent(clazz):
    assert type(clazz) == types.ClassType, 'must be a class...'
    module = namedModule(clazz.__module__)
    currclass = getattr(module, clazz.__name__, None)
    if currclass is None:
        return clazz
    return currclass
コード例 #2
0
 def getcurrent(clazz):
     assert type(clazz) == types.ClassType, 'must be a class...'
     module = namedModule(clazz.__module__)
     currclass = getattr(module, clazz.__name__, None)
     if currclass is None:
         return clazz
     return currclass
コード例 #3
0
ファイル: test_reflectpy3.py プロジェクト: hensing/twisted
 def test_namedModuleLookup(self):
     """
     L{namedModule} should return the module object for the name it is
     passed.
     """
     from twisted.python import monkey
     self.assertIdentical(
         reflect.namedModule("twisted.python.monkey"), monkey)
コード例 #4
0
ファイル: test_reflectpy3.py プロジェクト: 309972460/software
 def test_namedModuleLookup(self):
     """
     L{namedModule} should return the module object for the name it is
     passed.
     """
     from twisted.python import monkey
     self.assertIdentical(reflect.namedModule("twisted.python.monkey"),
                          monkey)
コード例 #5
0
    def reload_module(self, event, match):
        module_name = match.groupdict()['module']

        # okay, here's what's going to go down. First, we gonna find all the
        # plugins that use this module. Then we gonna unload them, see? Then we
        # gonna reload the module. Yeah? That's good. Then we's gonna get them
        # modules loaded back up. That should do it, ya think? I think it
        # should. Solid.

        plugins = [
            x for x in list(self.pluginboss.loaded_plugins.keys())
            if x.startswith(module_name + ".")
        ]
        log.msg("Request to reload module %s. Unloading these plugins: %s" % (
            module_name,
            ", ".join(plugins),
        ))

        for plugin_name in plugins:
            try:
                self.pluginboss.unload_plugin(plugin_name)
            except Exception:
                event.reply(
                    "Something went wrong unloading %s. Some plugins may have been unloaded. Check the error log!"
                    % plugin_name)
                raise
            else:
                log.msg("%s unloaded" % plugin_name)

        module = namedModule("abbott.plugins." + module_name)
        try:
            reload(module)
        except Exception:
            event.reply(
                "There was an error reloading the module. None of the plugins were reloaded. Check the log"
            )
            raise

        log.msg("%s reloaded" % module_name)

        for plugin_name in plugins:
            try:
                self.pluginboss.load_plugin(plugin_name)
            except Exception:
                event.reply(
                    "Something went wrong loading %s. Please see the error log"
                    % plugin_name)
            else:
                log.msg("%s loaded" % plugin_name)

        event.reply("Finished")
コード例 #6
0
ファイル: plugincontroller.py プロジェクト: L3viathan/abbott
    def reload_module(self, event, match):
        module_name = match.groupdict()['module']

        # okay, here's what's going to go down. First, we gonna find all the
        # plugins that use this module. Then we gonna unload them, see? Then we
        # gonna reload the module. Yeah? That's good. Then we's gonna get them
        # modules loaded back up. That should do it, ya think? I think it
        # should. Solid.

        plugins = [x for x in list(self.pluginboss.loaded_plugins.keys()) if x.startswith(module_name+".")]
        log.msg("Request to reload module %s. Unloading these plugins: %s" % (
            module_name,
            ", ".join(plugins),
            ))

        for plugin_name in plugins:
            try:
                self.pluginboss.unload_plugin(plugin_name)
            except Exception:
                event.reply("Something went wrong unloading %s. Some plugins may have been unloaded. Check the error log!" % plugin_name)
                raise
            else:
                log.msg("%s unloaded" % plugin_name)

        module = namedModule("abbott.plugins." + module_name)
        try:
            reload(module)
        except Exception:
            event.reply("There was an error reloading the module. None of the plugins were reloaded. Check the log")
            raise

        log.msg("%s reloaded" % module_name)

        for plugin_name in plugins:
            try:
                self.pluginboss.load_plugin(plugin_name)
            except Exception:
                event.reply("Something went wrong loading %s. Please see the error log" % plugin_name)
            else:
                log.msg("%s loaded" % plugin_name)

        event.reply("Finished")