Exemple #1
0
    def setupMainCode(self):
        # FIXME: imp.find_module does not work if self.moduleName contains
        # . like when checking flumotion.twisted.credentials
        #(handle, filename, (suffix, mode, type)) = imp.find_module(self.moduleName)
        handle, filename, smt = utils.findModule(self.moduleName,
                                                 self.moduleDir)
        # FIXME: if the smt[-1] == imp.PKG_DIRECTORY : load __all__
        # HACK: to make sibling imports work, we add self.moduleDir to sys.path
        # temporarily, and remove it later
        # FIXME: but how do we distinguish between system twisted (normal
        # import) and an import of twisted in flumotion.twisted module ?
        # That should report something like import is both sibling and system
        # module.
        if self.moduleDir is not None:
            oldsyspath = sys.path[:]
            sys.path.insert(0, self.moduleDir)
        module = imp.load_module(self.moduleName, handle, filename, smt)
        if self.moduleDir is not None:
            sys.path = oldsyspath
            # to make sure that subsequent modules with the same moduleName
            # do not persist, and get their namespace clobbered, delete it
            del sys.modules[self.moduleName]

        if filename.endswith('.so'):
            self.python = 0
            return module

        self.python = 1
        self._setupMainCode(handle, filename, module)
        return module
Exemple #2
0
    def setupMainCode(self):
        # FIXME: imp.find_module does not work if self.moduleName contains
        # . like when checking flumotion.twisted.credentials
        #(handle, filename, (suffix, mode, type)) = imp.find_module(self.moduleName)
        handle, filename, smt = utils.findModule(
            self.moduleName, self.moduleDir)
        # FIXME: if the smt[-1] == imp.PKG_DIRECTORY : load __all__
        # HACK: to make sibling imports work, we add self.moduleDir to sys.path
        # temporarily, and remove it later
        # FIXME: but how do we distinguish between system twisted (normal
        # import) and an import of twisted in flumotion.twisted module ?
        # That should report something like import is both sibling and system
        # module.
        if self.moduleDir is not None:
            oldsyspath = sys.path[:]
            sys.path.insert(0, self.moduleDir)
        module = imp.load_module(self.moduleName, handle, filename, smt)
        if self.moduleDir is not None:
            sys.path = oldsyspath
            # to make sure that subsequent modules with the same moduleName
            # do not persist, and get their namespace clobbered, delete it
            del sys.modules[self.moduleName]

        if filename.endswith('.so'):
            self.python = 0
            return module

        self.python = 1
        self._setupMainCode(handle, filename, module)
        return module
    def setupMainCode(self):
        handle, filename, smt = utils.findModule(
            self.moduleName, self.moduleDir)
        # FIXME: if the smt[-1] == imp.PKG_DIRECTORY : load __all__
        # HACK: to make sibling imports work, we add self.moduleDir to sys.path
        # temporarily, and remove it later
        if self.moduleDir is not None:
            oldsyspath = sys.path[:]
            sys.path.insert(0, self.moduleDir)
        module = imp.load_module(self.moduleName, handle, filename, smt)
        if self.moduleDir is not None:
            sys.path = oldsyspath
            # to make sure that subsequent modules with the same moduleName
            # do not persist, and get their namespace clobbered, delete it
            del sys.modules[self.moduleName]

        self._setupMainCode(handle, filename, module)
        return module
    def setupMainCode(self):
        handle, filename, smt = utils.findModule(self.moduleName,
                                                 self.moduleDir)
        # FIXME: if the smt[-1] == imp.PKG_DIRECTORY : load __all__
        # HACK: to make sibling imports work, we add self.moduleDir to sys.path
        # temporarily, and remove it later
        if self.moduleDir is not None:
            oldsyspath = sys.path[:]
            sys.path.insert(0, self.moduleDir)
        module = imp.load_module(self.moduleName, handle, filename, smt)
        if self.moduleDir is not None:
            sys.path = oldsyspath
            # to make sure that subsequent modules with the same moduleName
            # do not persist, and get their namespace clobbered, delete it
            del sys.modules[self.moduleName]

        self._setupMainCode(handle, filename, module)
        return module