Beispiel #1
0
    def load(self):
        print 'loading modules & looking for region classes'
        regclasses = []
        for mname in LOADMODS:
            osutil.load_or_reload(mname)
            m = sys.modules[mname]
            for name in dir(m):
                o = getattr(m, name)
                if name.startswith('_'):
                    continue
                try:
                    x = issubclass(o, INonSharedRegionModule)
                except TypeError:
                    pass
                else:
                    if x and getattr(o, 'autoload', None):
                        print 'found', name
                        regclasses.append(o)

        print 'instantiating found python modules'
        for klass in regclasses:
            ri = klass()
            ri.Initialise(self.config)
            print "register instance", ri
            self.reginstances.append(ri)
        print 'load done'
Beispiel #2
0
    def reload(self):
        log.Info("closing modules")
        for ri in self.reginstances:
            log.Debug("doing " + str(ri) + " from list of RM instances")
            if ri.Name in self.scene.RegionModules:
                print "also found in modules, so marking removed"
                ri.removed = True
                print "removing", ri.Name, "from self.scene.Modules"
                self.scene.RemoveRegionModule(ri.Name)
            else:
                print "not found in modules so not removing"
            ri.RemoveRegion(self.scene)
            ri.Close()

        self.reginstances[:] = []

        print 'reloading modules & looking for region classes'
        regclasses = []
        for mname in LOADMODS:
            osutil.load_or_reload(mname)
            m = sys.modules[mname]
            for name in dir(m):
                o = getattr(m, name)
                if name.startswith('_'):
                    continue
                try:
                    x = issubclass(o, INonSharedRegionModule)
                except TypeError:
                    pass
                else:
                    if x and getattr(o, 'autoload', None):
                        print 'found', name
                        regclasses.append(o)

        print 'instantiating found python modules'
        for klass in regclasses:
            ri = klass()
            ri.Initialise(self.config)
            print "register instance", ri
            self.reginstances.append(ri)
            self.scene.AddRegionModule(ri.Name, ri)
            ri.AddRegion(self.scene)
            ri.RegionLoaded(self.scene)
        print 'reload done'