def create_render_manager(base, config=None):
    if config is None:
        try:
            config = pman.get_config()
        except pman.NoConfigError:
            print(
                "RenderManager: Could not find pman config, falling back to basic plugin"
            )
            config = None

    renderplugin = config['general']['render_plugin'] if config else ''

    if not renderplugin:
        return BasicRenderManager(base)

    rppath = pman.get_abs_path(config, renderplugin)
    maindir = os.path.dirname(
        pman.get_abs_path(config, config['run']['main_file']))
    rppath = os.path.splitext(os.path.relpath(rppath, maindir))[0]
    module_parts = rppath.split(os.sep)

    modname = '.'.join(module_parts)
    print(modname)
    try:
        mod = pman.load_module(modname, config)
    except ImportError:
        print(
            "RenderManager: Could not find module ({}), falling back to basic plugin"
            .format(modname))
        return BasicRenderManager(base)

    return mod.get_plugin()(base)
Beispiel #2
0
def create_render_manager(base, config=None):
    if config is None:
        try:
            config = pman.get_config()
        except pman.NoConfigError:
            print(
                "RenderManager: Could not find pman config, falling back to basic plugin"
            )
            config = None

    renderplugin = config.get('general', 'render_plugin') if config else ''

    if not renderplugin:
        return BasicRenderManager(base)

    rppath = pman.get_abs_path(config, renderplugin)
    maindir = os.path.dirname(
        pman.get_abs_path(config, config.get('run', 'main_file')))
    rppath = os.path.splitext(os.path.relpath(rppath, maindir))[0]
    module_parts = rppath.split(os.sep)

    def load_module(modname, modinfo):
        mod = None
        try:
            mod = imp.load_module(modname, *modinfo)
        finally:
            if modinfo[0]:
                modinfo[0].close()

        return mod

    if pman.is_frozen():
        modname = '.'.join(module_parts)
        modinfo = imp.find_module(modname)
        mod = load_module(modname, modinfo)
    else:
        mod = None
        for modname in module_parts:
            modpath = None if mod is None else mod.__path__
            modinfo = imp.find_module(modname, modpath)
            mod = load_module(modname, modinfo)

    return mod.get_plugin()(base)
Beispiel #3
0
 def execute(self, _context):
     try:
         config = pman.get_config(
             os.path.dirname(bpy.data.filepath) if bpy.data.
             filepath else None)
         pman.create_project(pman.get_abs_path(config, ''))
         return {'FINISHED'}
     except pman.PManException as err:
         self.report({'ERROR'}, str(err))
         return {'CANCELLED'}
Beispiel #4
0
    def f(self):
        config = pman.get_config(os.path.dirname(bpy.data.filepath) if bpy.data.filepath else None)

        if conf_type == ConfTypes.string:
            value = config[section][field]
        elif conf_type == ConfTypes.path:
            # Convert from pman path to Blender path
            value = pman.get_abs_path(config, config[section][field])
            value = bpy.path.relpath(value)
        elif conf_type == ConfTypes.boolean:
            value = config.getboolean(section, field)
        else:
            raise TypeError("Unexpected conf_type {}".format(conf_type))

        #print("GET CONF", section, field, value)
        return value
def create_render_manager(base, config=None):
    if config is None:
        try:
            config = pman.get_config()
        except pman.NoConfigError:
            print("RenderManager: Could not find pman config, falling back to basic plugin")
            config = None

    renderplugin = config.get('general', 'render_plugin') if config else ''

    if not renderplugin:
        return BasicRenderManager(base)

    path = pman.get_abs_path(config, renderplugin)

    if HAS_SFL:
        mod = SourceFileLoader("render_plugin", path).load_module()
    else:
        mod = imp.load_source("render_plugin", path)

    return mod.get_plugin()(base)