def _getCOMModuleForLocation(self, componentFile): if not self._registred_pylib_paths: self._registred_pylib_paths = 1 try: self._setupPythonPaths() except: import traceback traceback.print_exc() fqn = componentFile.path if fqn[-4:] in (".pyc", ".pyo"): fqn = fqn[:-1] if not fqn.endswith(".py"): raise xpcom.ServerException(nsError.NS_ERROR_INVALID_ARG) mod = self.com_modules.get(fqn) if mod is not None: return mod import ihooks, sys base_name = os.path.splitext(os.path.basename(fqn))[0] loader = ihooks.ModuleLoader() module_name_in_sys = "component:%s" % (base_name, ) stuff = loader.find_module(base_name, [componentFile.parent.path]) assert stuff is not None, "Couldn't find the module '%s'" % ( base_name, ) py_mod = loader.load_module(module_name_in_sys, stuff) # Make and remember the COM module. comps = FindCOMComponents(py_mod) mod = self.moduleFactory(comps) self.com_modules[fqn] = mod return mod
def createInstance(self, outer, iid): if outer is not None: raise xpcom.ServerException(nsError.NS_ERROR_NO_AGGREGATION) if xpcom.verbose: print "Python Factory creating", self.klass.__name__ try: return self.klass() except: # An exception here may not be obvious to the user - none # of their code has been called yet. It can be handy on # failure to tell the user what class failed! _xpcom.LogWarning("Creation of class '%r' failed!\nException details follow\n" % (self.klass,)) raise
def createInstance(self, outer, iid): if outer is not None: raise xpcom.ServerException(nsError.NS_ERROR_NO_AGGREGATION) logger.debug("Python Factory creating %s", self.klass.__name__) try: return self.klass() except: # An exception here may not be obvious to the user - none # of their code has been called yet. It can be handy on # failure to tell the user what class failed! logger.error( "Creation of class '%r' failed!\nException details follow\n", self.klass) # The framework itself will also report the error. raise
def _getCOMModuleForLocation(self, componentFile): fqn = componentFile.path if not fqn.endswith(".py"): raise xpcom.ServerException(nsError.NS_ERROR_INVALID_ARG) mod = self.com_modules.get(fqn) if mod is not None: return mod import ihooks, sys base_name = os.path.splitext(os.path.basename(fqn))[0] loader = ihooks.ModuleLoader() module_name_in_sys = "component:%s" % (base_name, ) stuff = loader.find_module(base_name, [componentFile.parent.path]) assert stuff is not None, "Couldn't find the module '%s'" % ( base_name, ) py_mod = loader.load_module(module_name_in_sys, stuff) # Make and remember the COM module. comps = FindCOMComponents(py_mod) mod = self.moduleFactory(comps) self.com_modules[fqn] = mod return mod
def loadModuleFromJAR(self, aLocalFile, path): raise xpcom.ServerException(nsError.NS_ERROR_NOT_IMPLEMENTED)
# The contents of this file are subject to the Mozilla Public License Version