Пример #1
0
    def build_thumbnail_directory(self, src, dest, icon):
        srcPrefix = src + os.path.sep
        destPath = self.thumbdir + src[len(self.srcdir):]
        renderPath = self.renderdir + src[len(self.srcdir):]
        
        tree = self.get_dep_tree(src)
        root = src in self.dep_tree_roots
        
        mainfile = None
        inifile = os.path.join(src, "view.conf")
        if os.path.isfile(inifile):
            config = configparser.ConfigParser()
            config.read_file(ini_wrapper(inifile), inifile)
            mainfile = config.get("default", "main", fallback=None)

        bestFileSrc = None
        bestFileRender = None
        bestIsMain = False 
        bestBackDepsExists = False
        bestDepsCount = 0

        doAppend = True
        files = []
        for f in sorted(os.listdir(src)):
            if doAppend:
                files.append(f)
            else:
                files.insert(0, f)
            doAppend = not doAppend 
        
        for f in files:
            fileSrc = os.path.join(src, f)
            fileDest = os.path.join(destPath, f + self.suffix)
            fileRender = os.path.join(renderPath, f)
            if os.path.isfile(fileDest):
                isMain = f == mainfile
                depsCount = 0
                backDepsExists = root
                if fileSrc in tree:
                    for dep in tree[fileSrc]["fullDeps"]:
                        if dep[0:len(srcPrefix)] == srcPrefix or dep[0:len(renderPath)] == renderPath:
                            depsCount += 1
                    for dep in tree[fileSrc]["backDeps"]:
                        if dep[0:len(srcPrefix)] != srcPrefix and dep[0:len(renderPath)] != renderPath:
                            backDepsExists = True
                if ( not bestFileSrc
                     or (bestFileSrc and bestIsMain < isMain)
                     or (bestFileSrc and bestIsMain == isMain and not bestBackDepsExists < backDepsExists)
                     or (bestFileSrc and bestIsMain == isMain and bestBackDepsExists == backDepsExists and bestDepsCount < depsCount) ):
                    bestFileSrc = fileSrc
                    bestFileRender = fileRender
                    bestIsMain = isMain
                    bestBackDepsExists = backDepsExists
                    bestDepsCount = depsCount
                    
        if bestFileSrc:
            #print(_("Main file for '%s' is '%s', deps %s, back-deps %s") % (src, bestFileSrc[len(src):], bestDepsCount, bestBackDepsExists))
            return self.build_thumbnail_any(bestFileSrc, bestFileRender, dest, icon)
        else:
            return False, True 
Пример #2
0
    def _loadConfig(self, filename):

        config = configparser.ConfigParser()
        config.read_file(ini_wrapper(filename))

        for key in config.options('default'):
            self.config[key]=config.get('default', key)

        return True
Пример #3
0
    def _loadConfig(self, filename):

        config = configparser.ConfigParser()
        config.read_file(ini_wrapper(filename))

        for key in config.options('default'):
            self.config[key] = config.get('default', key)

        return True
def profile_items(scene, context):
    from renderchan.utils import ini_wrapper
    import configparser
    global rcl
    
    rcl.items = [("default", "Default", "The default profile")]
    if not rcl.blend or not os.path.exists(os.path.join(rcl.blend.projectPath, "project.conf")):
        return rcl.items
    config = configparser.ConfigParser()
    config.read_file(ini_wrapper(os.path.join(rcl.blend.projectPath, "project.conf")))
    for section in config.sections():
        if section != "default":
            rcl.items.append((section, section, ""))
    return rcl.items
def profile_items(scene, context):
    from renderchan.utils import ini_wrapper
    import configparser
    global rcl

    rcl.items = [("default", "Default", "The default profile")]
    if not rcl.blend or not os.path.exists(
            os.path.join(rcl.blend.projectPath, "project.conf")):
        return rcl.items
    config = configparser.ConfigParser()
    config.read_file(
        ini_wrapper(os.path.join(rcl.blend.projectPath, "project.conf")))
    for section in config.sections():
        if section != "default":
            rcl.items.append((section, section, ""))
    return rcl.items
Пример #6
0
    def build_thumbnail_directory(self, src, dest, icon):
        srcPrefix = src + os.path.sep
        destPath = self.thumbdir + src[len(self.srcdir):]
        renderPath = self.renderdir + src[len(self.srcdir):]

        tree = self.get_dep_tree(src)
        root = src in self.dep_tree_roots

        mainfile = None
        inifile = os.path.join(src, "view.conf")
        if os.path.isfile(inifile):
            config = configparser.ConfigParser()
            config.read_file(ini_wrapper(inifile), inifile)
            mainfile = config.get("default", "main", fallback=None)

        bestFileSrc = None
        bestFileRender = None
        bestIsMain = False
        bestBackDepsExists = False
        bestDepsCount = 0

        doAppend = True
        files = []
        for f in sorted(os.listdir(src)):
            if doAppend:
                files.append(f)
            else:
                files.insert(0, f)
            doAppend = not doAppend

        for f in files:
            fileSrc = os.path.join(src, f)
            fileDest = os.path.join(destPath, f + self.suffix)
            fileRender = os.path.join(renderPath, f)
            if os.path.isfile(fileDest):
                isMain = f == mainfile
                depsCount = 0
                backDepsExists = root
                if fileSrc in tree:
                    for dep in tree[fileSrc]["fullDeps"]:
                        if dep[0:len(srcPrefix)] == srcPrefix or dep[
                                0:len(renderPath)] == renderPath:
                            depsCount += 1
                    for dep in tree[fileSrc]["backDeps"]:
                        if dep[0:len(srcPrefix)] != srcPrefix and dep[
                                0:len(renderPath)] != renderPath:
                            backDepsExists = True
                if (not bestFileSrc or (bestFileSrc and bestIsMain < isMain)
                        or (bestFileSrc and bestIsMain == isMain
                            and not bestBackDepsExists < backDepsExists)
                        or (bestFileSrc and bestIsMain == isMain
                            and bestBackDepsExists == backDepsExists
                            and bestDepsCount < depsCount)):
                    bestFileSrc = fileSrc
                    bestFileRender = fileRender
                    bestIsMain = isMain
                    bestBackDepsExists = backDepsExists
                    bestDepsCount = depsCount

        if bestFileSrc:
            #print(_("Main file for '%s' is '%s', deps %s, back-deps %s") % (src, bestFileSrc[len(src):], bestDepsCount, bestBackDepsExists))
            return self.build_thumbnail_any(bestFileSrc, bestFileRender, dest,
                                            icon)
        else:
            return False, True
Пример #7
0
    def build_thumbnail_directory(self, src, dest, icon):
        srcPrefix = src + os.path.sep
        
        tree = self.get_dep_tree(src)
        root = src in self.dep_tree_roots
        
        mainfile = None
        inifile = os.path.join(src, "view.conf")
        if os.path.isfile(inifile):
            config = configparser.ConfigParser()
            config.read_file(ini_wrapper(inifile), inifile)
            mainfile = config.get("default", "main", fallback=None)

        bestFileSrc = None
        bestFileRender = None
        bestIsMain = False 
        bestBackDepsExists = False
        bestDepsCount = 0

        files = []
        files_orig = sorted(os.listdir(src)); 
        while files_orig:
            files.append(files_orig.pop(len(files_orig)//2))
        print(files)
        
        for f in files:
            fileSrc = os.path.join(src, f)
            if fileSrc not in self.thumbs:
                continue
            fileDest = self.thumbs[fileSrc]["thumb"]
            fileRender = self.thumbs[fileSrc]["render"]
            fileRenderDir = os.path.dirname(fileRender)
            if os.path.isfile(fileDest):
                isMain = f == mainfile
                depsCount = 0
                backDepsExists = root
                if fileSrc in tree:
                    for dep in tree[fileSrc]["fullDeps"]:
                        if dep[0:len(srcPrefix)] == srcPrefix or dep[0:len(fileRenderDir)] == fileRenderDir:
                            depsCount += 1
                    for dep in tree[fileSrc]["backDeps"]:
                        if dep[0:len(srcPrefix)] != srcPrefix and dep[0:len(fileRenderDir)] != fileRenderDir:
                            backDepsExists = True
                if ( not bestFileSrc
                     or (bestFileSrc and bestIsMain < isMain)
                     or (bestFileSrc and bestIsMain == isMain and not bestBackDepsExists and backDepsExists)
                     or (bestFileSrc and bestIsMain == isMain and bestBackDepsExists == backDepsExists and bestDepsCount < depsCount) ):
                    bestFileSrc = fileSrc
                    bestFileRender = fileRender
                    bestIsMain = isMain
                    bestBackDepsExists = backDepsExists
                    bestDepsCount = depsCount
                    
        if bestFileSrc:
            #print(_("Main file for '%s' is '%s', deps %s, back-deps %s") % (src, bestFileSrc[len(src):], bestDepsCount, bestBackDepsExists))
            _, processed, success = self.build_thumbnail_any(bestFileSrc, bestFileRender, dest, None)
            if icon and processed and success:
                success = self.run_pipe([
                    self.command_template_thumbnail(src = icon),
                    self.command_composite(src = dest, dest = dest) ])
            return processed, success;
        else:
            return False, True 
Пример #8
0
    def loadRenderConfig(self, profile=None):
        """
        :type profile: str
        """
        if self.version == 0 and profile != None:

            print(
                "Warning: Profiles are not supported with old project format. No profile loaded."
            )
            return False

        elif self.version == 0:

            # Old project format, used by Remake

            config = configparser.ConfigParser()
            config.read_file(ini_wrapper(self.confPath))

            for key in config.options('default'):
                self.config[key] = config.get('default', key)
        else:

            # Native RenderChan project format

            config = configparser.ConfigParser()
            config.readfp(open(self.confPath))

            # sanity check
            for section in config.sections():
                if "." in section:
                    print(
                        "Warning: Incorrect profile name found (%s) - dots are not allowed."
                        % (section))

            if profile == None:
                if config.has_option("main", "active_profile"):
                    profile = config.get("main", "active_profile")
                else:
                    if len(config.sections()) != 0:
                        profile = config.sections()[0]
                    else:
                        return False

            profile = profile.replace(".", "")

            for key in config.options(profile):
                self.config[key] = config.get(profile, key)

            # check for correct values
            if self.getConfig("stereo") != "left" and self.getConfig(
                    "stereo") != "right":
                self.config["stereo"] = ""

            self.activeProfile = profile

        # Store project configuration - we need that to track configuration changes
        profilepath = self.getProfilePath()
        if not os.path.isdir(profilepath):
            mkdirs(profilepath)

        filename = os.path.join(profilepath, "core.conf")
        oldconfig = {}
        if os.path.exists(filename):
            cp = configparser.ConfigParser()
            cp.read(filename)

            for key in cp.options('main'):
                oldconfig[key] = cp.get('main', key)

        newconfig = self.defaults.copy()
        for key in self.config.keys():
            if key in self.defaults.keys():
                newconfig[key] = self.config[key]

        if newconfig != oldconfig:
            config = configparser.ConfigParser()
            config.add_section('main')
            for key in newconfig.keys():
                config.set('main', key, newconfig[key])
            with open(filename, 'w') as configfile:
                config.write(configfile)

        # Store current profile
        #filename=os.path.join(self.path,"render","project.conf","profile.conf")
        #prev_profile = ""
        #if os.path.exists(filename):
        #    # Read previous profile
        #    f=open(filename)
        #    prev_profile = f.readlines()[0].strip()
        #    f.close()
        #if prev_profile!=self.getProfileDirName():
        #    f = open(filename,'w')
        #    f.write(self.getProfileDirName()+"\n")
        #    f.close()

        return True
Пример #9
0
    def build_thumbnail_directory(self, src, dest, icon):
        srcPrefix = src + os.path.sep

        tree = self.get_dep_tree(src)
        root = src in self.dep_tree_roots

        mainfile = None
        inifile = os.path.join(src, "view.conf")
        if os.path.isfile(inifile):
            config = configparser.ConfigParser()
            config.read_file(ini_wrapper(inifile), inifile)
            mainfile = config.get("default", "main", fallback=None)

        bestFileSrc = None
        bestFileRender = None
        bestIsMain = False
        bestBackDepsExists = False
        bestDepsCount = 0

        files = []
        files_orig = sorted(os.listdir(src))
        while files_orig:
            files.append(files_orig.pop(len(files_orig) // 2))
        print(files)

        for f in files:
            fileSrc = os.path.join(src, f)
            if fileSrc not in self.thumbs:
                continue
            fileDest = self.thumbs[fileSrc]["thumb"]
            fileRender = self.thumbs[fileSrc]["render"]
            fileRenderDir = os.path.dirname(fileRender)
            if os.path.isfile(fileDest):
                isMain = f == mainfile
                depsCount = 0
                backDepsExists = root
                if fileSrc in tree:
                    for dep in tree[fileSrc]["fullDeps"]:
                        if dep[0:len(srcPrefix)] == srcPrefix or dep[
                                0:len(fileRenderDir)] == fileRenderDir:
                            depsCount += 1
                    for dep in tree[fileSrc]["backDeps"]:
                        if dep[0:len(srcPrefix)] != srcPrefix and dep[
                                0:len(fileRenderDir)] != fileRenderDir:
                            backDepsExists = True
                if (not bestFileSrc or (bestFileSrc and bestIsMain < isMain)
                        or (bestFileSrc and bestIsMain == isMain
                            and not bestBackDepsExists and backDepsExists)
                        or (bestFileSrc and bestIsMain == isMain
                            and bestBackDepsExists == backDepsExists
                            and bestDepsCount < depsCount)):
                    bestFileSrc = fileSrc
                    bestFileRender = fileRender
                    bestIsMain = isMain
                    bestBackDepsExists = backDepsExists
                    bestDepsCount = depsCount

        if bestFileSrc:
            #print(_("Main file for '%s' is '%s', deps %s, back-deps %s") % (src, bestFileSrc[len(src):], bestDepsCount, bestBackDepsExists))
            _, processed, success = self.build_thumbnail_any(
                bestFileSrc, bestFileRender, dest, None)
            if icon and processed and success:
                success = self.run_pipe([
                    self.command_template_thumbnail(src=icon),
                    self.command_composite(src=dest, dest=dest)
                ])
            return processed, success
        else:
            return False, True
Пример #10
0
    def loadRenderConfig(self, profile=None):

        """
        :type profile: str
        """
        if self.version==0 and profile!=None:

            print("Warning: Profiles are not supported with old project format. No profile loaded.")
            return False

        elif self.version==0:

            # Old project format, used by Remake

            config = configparser.ConfigParser()
            config.read_file(ini_wrapper(self.confPath))

            for key in config.options('default'):
                self.config[key]=config.get('default', key)
        else:

            # Native RenderChan project format

            config = configparser.ConfigParser()
            config.readfp(open(self.confPath))

            # sanity check
            for section in config.sections():
                if "." in section:
                    print("Warning: Incorrect profile name found (%s) - dots are not allowed." % (section))

            if profile==None:
                if config.has_option("main", "active_profile"):
                    profile=config.get("main", "active_profile")
                else:
                    if len(config.sections())!=0:
                        profile = config.sections()[0]
                    else:
                        return False

            profile=profile.replace(".","")

            for key in config.options(profile):
                self.config[key]=config.get(profile, key)

            # check for correct values
            if self.getConfig("stereo")!="left" and self.getConfig("stereo")!="right":
                self.config["stereo"]=""

            self.activeProfile=profile



        # Store project configuration - we need that to track configuration changes
        profilepath = self.getProfilePath()
        if not os.path.isdir(profilepath):
            mkdirs(profilepath)

        filename=os.path.join(profilepath,"core.conf")
        oldconfig={}
        if os.path.exists(filename):
            cp = configparser.ConfigParser()
            cp.read(filename)

            for key in cp.options('main'):
                oldconfig[key]=cp.get('main', key)

        newconfig=self.defaults.copy()
        for key in self.config.keys():
            if key in self.defaults.keys():
                newconfig[key]=self.config[key]

        if newconfig!=oldconfig:
            config = configparser.ConfigParser()
            config.add_section('main')
            for key in newconfig.keys():
                config.set('main', key, newconfig[key])
            with open(filename, 'w') as configfile:
                config.write(configfile)

        # Store current profile
        #filename=os.path.join(self.path,"render","project.conf","profile.conf")
        #prev_profile = ""
        #if os.path.exists(filename):
        #    # Read previous profile
        #    f=open(filename)
        #    prev_profile = f.readlines()[0].strip()
        #    f.close()
        #if prev_profile!=self.getProfileDirName():
        #    f = open(filename,'w')
        #    f.write(self.getProfileDirName()+"\n")
        #    f.close()

        return True