Example #1
0
    def __init__(self, wok_options):
        make_dirs = [
            os.path.dirname(os.path.abspath(config.get_object_store())),
        ]
        for directory in make_dirs:
            if not os.path.isdir(directory):
                os.makedirs(directory)

        if hasattr(wok_options, "model"):
            self.model = wok_options.model
        elif wok_options.test:
            self.model = mockmodel.MockModel()
        else:
            self.model = gingerS390xModel.Model()

        dev_env = wok_options.environment != 'production'
        super(GingerS390x, self).__init__(self.model, dev_env)

        for ident, node in sub_nodes.items():
            setattr(self, ident, node(self.model))

        self.api_schema = json.load(
            open(
                os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             'API.json')))
        self.paths = config.gingerS390xPaths
        self.domain = 'gingers390x'
        self.messages = messages
Example #2
0
    def __init__(self, wok_options):
        make_dirs = [
            os.path.dirname(os.path.abspath(config.get_object_store())),
        ]
        for directory in make_dirs:
            if not os.path.isdir(directory):
                os.makedirs(directory)

        if hasattr(wok_options, "model"):
            self.model = wok_options.model
        elif wok_options.test:
            self.model = mockmodel.MockModel()
        else:
            self.model = gingerS390xModel.Model()

        dev_env = wok_options.environment != 'production'
        super(GingerS390x, self).__init__(self.model, dev_env)

        for ident, node in sub_nodes.items():
            setattr(self, ident, node(self.model))

        self.api_schema = json.load(open(os.path.join(os.path.dirname(
                                    os.path.abspath(__file__)), 'API.json')))
        self.paths = config.gingerS390xPaths
        self.domain = 'gingers390x'
        self.messages = messages
Example #3
0
    def __init__(self, objstore_loc=None):

        def get_instances(module_name):
            instances = []
            module = import_module(module_name)
            members = inspect.getmembers(module, inspect.isclass)
            for cls_name, instance in members:
                if inspect.getmodule(instance) == module and \
                   cls_name.endswith('Model'):
                    instances.append(instance)

            return instances

        if objstore_loc is None:
            objstore_loc = config.get_object_store()

        self.objstore = ObjectStore(objstore_loc)
        kargs = {'objstore': self.objstore}

        models = []
        # Import task model from Wok
        instances = get_instances('wok.model.tasks')
        for instance in instances:
            models.append(instance(**kargs))

        # Import all gingers390x plugin models
        this = os.path.basename(__file__)
        this_mod = os.path.splitext(this)[0]

        for mod_name in listPathModules(os.path.dirname(__file__)):
            if mod_name.startswith("_") or mod_name == this_mod:
                continue

            instances = get_instances(
                'wok.plugins.gingers390x.model.' + mod_name
            )
            for instance in instances:
                models.append(instance(**kargs))

        return super(Model, self).__init__(models)
Example #4
0
    def __init__(self, objstore_loc=None):
        def get_instances(module_name):
            instances = []
            module = import_module(module_name)
            members = inspect.getmembers(module, inspect.isclass)
            for cls_name, instance in members:
                if inspect.getmodule(instance) == module and \
                   cls_name.endswith('Model'):
                    instances.append(instance)

            return instances

        if objstore_loc is None:
            objstore_loc = config.get_object_store()

        self.objstore = ObjectStore(objstore_loc)
        kargs = {'objstore': self.objstore}

        models = []
        # Import task model from Wok
        instances = get_instances('wok.model.tasks')
        for instance in instances:
            models.append(instance(**kargs))

        # Import all gingers390x plugin models
        this = os.path.basename(__file__)
        this_mod = os.path.splitext(this)[0]

        for mod_name in listPathModules(os.path.dirname(__file__)):
            if mod_name.startswith("_") or mod_name == this_mod:
                continue

            instances = get_instances('wok.plugins.gingers390x.model.' +
                                      mod_name)
            for instance in instances:
                models.append(instance(**kargs))

        return super(Model, self).__init__(models)