Example #1
0
    def _import(self, instance, name):

        factoryName = self.family
        path = name.split(':')
        c = len(path)
        if c == 1:
            factoryPath = [factoryName]
        elif c == 2:
            factoryPath = path[1].split('.')
            if not factoryPath[-1]:
                factoryPath.pop()
                if not factoryPath:
                    factoryPath.append(factoryName)
            else:
                factoryPath.append(factoryName)
        else:
            raise Facility.ComponentNotFound(facility=self.name,
                                             component=name)
        module = path[0]
        factoryName = '.'.join(factoryPath)
        objName = module + ':' + factoryName

        try:
            from pyre.util import loadObject
            factory = loadObject(objName)
        except (ImportError, ValueError):
            raise Facility.ComponentNotFound(facility=self.name,
                                             component=name)
        except AttributeError:
            raise Facility.FactoryNotFound(facility=self.name,
                                           module=module,
                                           factory=factoryName)

        if not callable(factory):
            raise Facility.FactoryNotCallable(facility=self.name,
                                              module=module,
                                              factory=factoryName)

        item = factory(*self.args)

        return item
Example #2
0
    def _import(self, instance, name):

        factoryName = self.family
        path = name.split(':')
        c = len(path)
        if c == 1:
            factoryPath = [factoryName]
        elif c == 2:
            factoryPath = path[1].split('.')
            if not factoryPath[-1]:
                factoryPath.pop()
                if not factoryPath:
                    factoryPath.append(factoryName)
            else:
                factoryPath.append(factoryName)
        else:
            raise Facility.ComponentNotFound(
                facility=self.name, component=name)
        module = path[0]
        factoryName = '.'.join(factoryPath)
        objName = module + ':' + factoryName

        try:
            from pyre.util import loadObject
            factory = loadObject(objName)
        except (ImportError, ValueError):
            raise Facility.ComponentNotFound(
                facility=self.name, component=name)
        except AttributeError:
            raise Facility.FactoryNotFound(
                facility=self.name, module=module, factory=factoryName)

        if not callable(factory):
            raise Facility.FactoryNotCallable(
                facility=self.name, module=module, factory=factoryName)

        item = factory(*self.args)

        return item
Example #3
0
 def _init(self):
     super(BatchScript, self)._init()
     self.SchedulerClass = loadObject(self.schedulerClass)
     return
Example #4
0
 def _init(self):
     super(BatchScript, self)._init()
     self.SchedulerClass = loadObject(self.schedulerClass)
     return
Example #5
0
 def createSubscript(self, name):
     from pyre.util import loadObject
     cls = loadObject(name)
     return cls()