Exemplo n.º 1
0
def collapseToKeyPrjData(path):
    from collections import OrderedDict

    templateConfigPath = configUtils.templateConfigFile
    mainTemplate = configUtils.loadConfigData(
        templateConfigPath)['projectTemplate']
    configKeys = [r'{projectName}', r'{episodName}', r'{shotName}']

    keyPrjData = {"project": None, "episod": None, "shot": None}
    keyPrjData = OrderedDict(
        sorted(keyPrjData.items(), key=lambda x: len(x[0]), reverse=True))
    for d in configKeys:
        idx = mainTemplate.find(d)
        depthTemplate = mainTemplate[:idx]

        pattern = re.escape(depthTemplate)
        pattern = re.sub(r"\\\\", r"[\\\\|\/]", pattern, flags=re.IGNORECASE)
        pattern += r"(.+?)(\\|\/|\b)"
        matchPath = re.match(pattern, path, flags=re.IGNORECASE)
        if matchPath:
            depthName = matchPath.group(1)

            key = d.replace("Name", "")
            key = key.replace("{", "")
            key = key.replace("}", "")
            keyPrjData[key] = depthName
            mainTemplate = mainTemplate.replace(d, depthName)

    return dict(keyPrjData)
Exemplo n.º 2
0
    def updateFramesCount(self):
        from _lib.ffmpeg_lib import ffprobeUtils
        from UI.UserTaskManager.utils import projectUtils

        nkConifg = configUtils.nukeConfigFile

        fps = configUtils.loadConfigData(nkConifg).get('FPS')
        project = self.taskManagerWdg.getActiveProject()
        items = self.itemUtils.getSelected_shotItems()

        server = self.taskManagerWdg.userServerCore.server
        server.start()
        for item in items:
            keyPrjData = projectUtils.getKeyPrjData(project, item)

            prm = pathUtils.getPRM_filePath(keyPrjData)
            duration = ffprobeUtils.getDuration(prm) if prm else 0
            frames = round(duration * int(fps))
            skey = item.data(0, Qt.UserRole)
            tacticPostUtils.updateSobject(server, skey,
                                          {"frames_count": frames})

            print(
                f"Shot {keyPrjData.get('shot')} duration is '{frames}' frames")
        server.finish()
Exemplo n.º 3
0
    def updateList(self, depthData, depthIndx=0):
        newDepthData = dict(depthData)
        path = keyDataProjectUtils.getKeyPrjPath(newDepthData, depthIndx)
        if os.path.exists(path) is False:
            return None

        depthLevel = list(newDepthData.keys())[depthIndx]
        self.depthData = dict(newDepthData)
        self.clear()

        rootItem = QListWidgetItem("...")
        rootItem.setData(Qt.UserRole, "ROOT")
        self.addItem(rootItem)

        if depthIndx == 0:
            activeProjectsFilePath = configUtils.activeProjectsFile
            activeProjectsList = configUtils.loadConfigData(
                activeProjectsFilePath)
            if activeProjectsList is not None:
                self.fillProjectsView(path, newDepthData, depthLevel,
                                      activeProjectsList)
            else:
                self.fillOtherView(path, newDepthData, depthLevel)
        else:
            self.fillOtherView(path, newDepthData, depthLevel)
Exemplo n.º 4
0
def projectSettingsProcess(configFileList, render):
    envsVariables = dict()
    projectVariables = collectProjectVariables(configFileList)
    pathEnvsVariables = dict()
    renderEnvsVariables = dict()
    assetPathsVariables = collectAssetPathsVariables(configFileList)

    collectRenderEnvsVariables(configFileList, renderEnvsVariables, render)

    for config in configFileList:
        configData = configUtils.loadConfigData(config)
        if configData is None:
            continue
        if isinstance(configData, list):
            collectEnvsVariables(configData, envsVariables)
            collectPathEnvsVariables(configData, pathEnvsVariables)
        else:
            print("Config file: {config} contains unexpected data".format(
                config=config))

    pathEnvsVariables = merge_twoPathDict(renderEnvsVariables,
                                          pathEnvsVariables)
    pathEnvsVariables = merge_twoPathDict(assetPathsVariables,
                                          pathEnvsVariables)
    envsVariables = configUtils.merge_two_dicts(projectVariables,
                                                envsVariables)

    pathEnvsVariables = completeAllPathEnvVariables(pathEnvsVariables)

    allEnvironmentVariables = configUtils.merge_two_dicts(
        pathEnvsVariables, envsVariables)
    allEnvironmentVariables['HOUDINI_DIR'] = allEnvironmentVariables[
        'location'].format(ver=allEnvironmentVariables['version'])

    return allEnvironmentVariables
Exemplo n.º 5
0
    def completeTree(self, data):
        # self.blockSignals(True)
        filterElement = self.shotFilter
        # filterItems=True
        # print(filterElement)
        self.allUsers = self.taskManagerWdg.getAllPrjUsers()
        # self.createUsersComboBox(self.taskManagerWdg.userServerCore.allUsers)
        # print("TREE DATA = ", data)
        self.blockSignals(True)
        self.clear()
        # if filterItems:
        self.addTreeItemFilter(data, filterElement)
        self.removeWaste()
        # else:
        #     self.addTreeItem(data)
        # self.sortItems(0, Qt.AscendingOrder)

        isExpanded = configUtils.loadConfigData(taskManagerConfigFile).get(
            "treeExpand")
        if isExpanded:
            self.expandAllTree()
        else:
            self.collapseAllTree()

        self.setSelectedItem()
        self.blockSignals(False)
Exemplo n.º 6
0
 def initialzePreData(self):
     credData = configUtils.loadConfigData(crPath)
     try:
         self.userIpAdressField.setText(credData.get('IpAdress'))
         self.userNameField.setText(credData.get('userName'))
         self.userPasswordField.setText(credData.get('password'))
     except Exception:
         pass
Exemplo n.º 7
0
 def getCurrentConfigData(self, index=None):
     index = self.tabWidget.currentIndex() if index is None else index
     configPath = self.getCurrentConfigPath(index)
     if configPath is None:
         return None
     if os.path.exists(configPath):
         configData = configUtils.loadConfigData(configPath)
     else:
         configData = [{"Config file is not exists": ""}]
     return configData
Exemplo n.º 8
0
def getLocalNukeLocation(ver):

    configFile = configUtils.configLocal
    if not os.path.exists(configFile):
        configUtils.saveConfigData(configFile, dict())

    localNukeLocation = configUtils.loadConfigData(
        configUtils.configLocal).get('NUKE_location')
    nukeLocation = ""
    if localNukeLocation:
        rootDir, nukeDir = os.path.split(localNukeLocation)
        nukeDir = "/".join([rootDir, r"Nuke{ver}"])
        nukeLocation = nukeDir.format(ver=ver)
    return nukeLocation
Exemplo n.º 9
0
    def setActive(self):
        projectNameList = self.projectListWidget.selectedItems()

        filePath = activeProjectsFile
        data = configUtils.loadConfigData(filePath)
        data = [] if data is None else data

        for projectName in projectNameList:
            if projectName.text() in data:
                data.pop(data.index(projectName.text()))
            else:
                data.append(projectName.text())

            configUtils.saveConfigData(filePath, data)
            self.updateActiveProjectList()
Exemplo n.º 10
0
def collectAssetPathsVariables(configFileList):
    configFileList = [
        f.replace("\\config.json", "") for f in configFileList[1:]
    ]
    configData = dict()
    try:
        configData[r'{projectName}'] = configFileList[0]
    except IndexError:
        pass
    try:
        configData[r'{episodName}'] = configFileList[1]
    except IndexError:
        pass
    try:
        configData[r'{shotName}'] = configFileList[2]
    except IndexError:
        pass

    otlPaths = {"HOUDINI_OTLSCAN_PATH": []}

    templateConfigFilePath = configUtils.templateConfigFile
    templateData = configUtils.loadConfigData(
        templateConfigFilePath)['OTLPaths']
    # del templateData['projectTemplate']

    rawTemplates = [x for x in templateData.values()]

    for templ in rawTemplates:
        for k in configData.keys():
            if templ.find(k) >= 0:
                templ = templ.replace(k, configData[k])

                indx = templ.find(r"{assetName}")
                if indx == -1:
                    print(
                        "Wrong OTL Path template: Asset template must have '{assetName}' part"
                    )
                    continue
                pathToAssets = templ[:indx]
                if os.path.exists(pathToAssets):
                    for element in os.listdir(pathToAssets):
                        if os.path.isdir(os.path.join(pathToAssets, element)):
                            otlPath = templ.format(assetName=element)
                            if os.path.exists(otlPath):
                                otlPaths["HOUDINI_OTLSCAN_PATH"].append(
                                    otlPath)

    return otlPaths
Exemplo n.º 11
0
    def updateTemplate(self):
        templatesData = configUtils.loadConfigData(templateConfigFile)
        if templatesData is None:
            return None
        self.templateStructureProject.setText(templatesData['projectTemplate'])

        print(templatesData)
        otlPathData = templatesData['OTLPaths']
        self.templateOtlPath_prj.setText(otlPathData['OTLPath_prj'])
        self.templateOtlPath_epi.setText(otlPathData['OTLPath_epi'])
        self.templateOtlPath_shot.setText(otlPathData['OTLPath_shot'])

        workPathData = templatesData['Work_Paths']
        self.templateWorkPath_prj.setText(workPathData['workPath_prj'])
        self.templateWorkPath_epi.setText(workPathData['workPath_epi'])
        self.templateWorkPath_shot.setText(workPathData['workPath_shot'])
Exemplo n.º 12
0
def getNukeConfigData(keyPrjPathsList):
    configPathsList = []
    configPathsList = [os.path.join(x, "config.json") for x in keyPrjPathsList]
    configPathsList.insert(0, configUtils.mainProjectConfigFile)

    mainNkData = dict()
    for config in configPathsList:
        configData = configUtils.loadConfigData(config)

        if configData is None:
            continue
        try:
            nkConfigData = [data for data in configData
                            if data.get('NUKE')][0].get('NUKE')
            [mainNkData.update(data) for data in nkConfigData]
        except IndexError:
            continue
    return mainNkData
Exemplo n.º 13
0
def getKeyPrjPath(keyPrjData, depthIndex=None, nameInclude=False):

    if nameInclude:
        pattern = r"((((.*){projectName}).*{episodName}).*{shotName})"
    else:
        pattern = r"((((.*){projectName}.*){episodName}.*){shotName}.*)"

    depthIndex = getDepth(keyPrjData) if depthIndex is None else depthIndex

    template = configUtils.loadConfigData(
        configUtils.templateConfigFile)['projectTemplate']
    template = list(re.findall(pattern, template)[0])

    template = template[::-1][depthIndex]

    path = template.format(projectName=keyPrjData['project'],
                           episodName=keyPrjData['episod'],
                           shotName=keyPrjData['shot'])
    return path.rstrip("/")
Exemplo n.º 14
0
def collectRenderEnvsVariables(configList, caseEnvsData, render):

    if render == "Mantra":
        caseEnvsData['RENDER'] = ["Mantra"]
        return

    renderDataList = []
    for config in configList:
        configData = configUtils.loadConfigData(config)
        # configData = getJsonData(config)
        if configData is None:
            continue
        configData = getVariabelElement(configData, 'renders')
        if configData is None:
            continue
        renderDataList.append(configData)

    try:
        configData = renderDataList[-1]
    except IndexError:
        caseEnvsData['RENDER'] = ["Mantra"]
        # caseEnvsData = {}
        return None

    if render is None:
        renderItems = [list(x.keys())[0] for x in configData]
        if len(renderItems) > 1:
            selectedItems = selectDialog.executeDialog(renderItems)
        else:
            selectedItems = renderItems

    else:
        selectedItems = render.split(";")

    if len(selectedItems) == 0:
        caseEnvsData['RENDER'] = ["Mantra"]
        return None

    caseEnvsData['RENDER'] = selectedItems
    for data in configData:
        if list(data.keys())[0] in selectedItems:
            collectDeepEnvsData(list(data.values())[0], caseEnvsData)
Exemplo n.º 15
0
def getNukeLocation(ver, afRender=False):
    from platform import system
    nukeDir = ""
    if system() is 'Windows':
        nukeDir = "/".join(['C:', 'Program Files', r'Nuke{ver}'])
    elif system() is 'Linux':
        nukeDir = ''
    elif system() == 'Darwin':
        nukeDir = ''

    nukeLocation = nukeDir.format(ver=ver)
    if not os.path.exists(nukeLocation):
        nukeLocation = getLocalNukeLocation(ver)

    if not os.path.exists(nukeLocation):
        if afRender:
            print('===> Nuke location not found!')
            raise FileNotFoundError
        else:
            while not os.path.exists(nukeLocation):
                dialog = simpleDialogs.PathFileDialog()
                text = 'Specify the nuke folder please. \nRecomended verison is: Nuke"{}"'.format(
                    ver)
                nukeLocation = dialog.showDialog(text)
                if nukeLocation is None:
                    return None, None

                localData = configUtils.loadConfigData(configUtils.configLocal)
                localData['NUKE_location'] = nukeLocation
                configUtils.saveConfigData(configUtils.configLocal, localData)

    pattern = r'^Nuke\d{1,2}(\.\d{1,2}(\.\d{1,2})?)?\.exe$'
    try:
        nukeExe = list(
            filter(lambda x: re.search(pattern, x),
                   os.listdir(nukeLocation)))[0]
    except FileNotFoundError as err:
        print('===> Nuke location not found!')
        raise err

    return nukeLocation, nukeExe
Exemplo n.º 16
0
def getInitSystemEnvs():
    tempFile = os.path.join(os.getenv('APPDATA'), "cgpipeline",
                            "initSystemEnvs.json")
    return configUtils.loadConfigData(tempFile)
Exemplo n.º 17
0
 def completTreeData(self):
     path = "/".join([os.path.dirname(__file__), "treeData.json"])
     treeData = configUtils.loadConfigData(path)
     if treeData:
         treeWdg_utils.completeTree(self, treeData, editable=True)
         treeWdg_utils.expandAllTree(self)
Exemplo n.º 18
0
 def collapseAllTree(self):
     treeWdg_utils.collapseAllTree(self)
     # self.setSelectedItem()
     configData = configUtils.loadConfigData(taskManagerConfigFile)
     configData["treeExpand"] = False
     configUtils.saveConfigData(taskManagerConfigFile, configData)
Exemplo n.º 19
0
 def expandAllTree(self):
     treeWdg_utils.expandAllTree(self)
     # self.setSelectedItem()
     configData = configUtils.loadConfigData(taskManagerConfigFile)
     configData["treeExpand"] = True
     configUtils.saveConfigData(taskManagerConfigFile, configData)
Exemplo n.º 20
0
 def createFolderSturcture(self, treeData):
     prjStructureConfig = configUtils.projectStructureConfigFile
     treeFolderStructure = configUtils.loadConfigData(prjStructureConfig)
     paths = treeWdg_utils.getPathsData(treeFolderStructure)
     pathCollection = self.collectAllPaths(paths, self.prjCode, treeData)
     self.createFolders(pathCollection)
Exemplo n.º 21
0
 def loadActiveProject(self):
     activeProject = configUtils.loadConfigData(taskManagerConfigFile).get(
         "activeProject")
     return activeProject
Exemplo n.º 22
0
 def saveActiveProject(self, project):
     configData = configUtils.loadConfigData(taskManagerConfigFile)
     configData["activeProject"] = project
     configUtils.saveConfigData(taskManagerConfigFile, configData)