def collectCacheVersion(self) : versions = [] if self.setting : cachePath = self.setting['cachePath'] cacheInfo = dict() if os.path.exists(cachePath) : versions = fileUtils.listFolder(cachePath) for version in versions : files = fileUtils.listFile(os.path.join(cachePath, version)) assetNames = [os.path.splitext(a)[0] for a in files] i = 0 for eachFile in assetNames : assetName = eachFile if not assetName in cacheInfo.keys() : cacheInfo.update({assetName: {'versions': [version], 'versionKey': {version: os.path.join(cachePath, version, files[i])}}}) else : cacheInfo[assetName]['versions'].append(version) cacheInfo[assetName]['versionKey'].update({version: os.path.join(cachePath, version, files[i])}) i += 1 return cacheInfo
def setSubTypeUI(self): crSubType = str() if self.info: crSubType = self.info['assetSubtype'] project = str(self.ui.project_comboBox.currentText()) selType = str(self.ui.type_comboBox.currentText()) path = '%s%s/asset/3D/%s' % (self.drive, project, selType) subTypes = fileUtils.listFolder(path) self.ui.subType_comboBox.clear() i = 0 index = 0 for each in subTypes: self.ui.subType_comboBox.addItem(each) if each == crSubType: index = i i += 1 self.ui.subType_comboBox.setCurrentIndex(index)
def listAssetUI(self): crAsset = str() if self.info: crAsset = self.info['assetName'] project = str(self.ui.project_comboBox.currentText()) selType = str(self.ui.type_comboBox.currentText()) selSubType = str(self.ui.subType_comboBox.currentText()) path = '%s%s/asset/3D/%s/%s' % (self.drive, project, selType, selSubType) assets = fileUtils.listFolder(path) self.ui.asset_comboBox.clear() index = 0 i = 0 for each in assets: self.ui.asset_comboBox.addItem(each) if each == crAsset: index = i i += 1 self.ui.asset_comboBox.setCurrentIndex(index)
def setSubTypeUI(self) : crSubType = str() if self.info : crSubType = self.info['assetSubtype'] project = str(self.ui.project_comboBox.currentText()) selType = str(self.ui.type_comboBox.currentText()) path = '%s%s/asset/3D/%s' % (self.drive, project, selType) subTypes = fileUtils.listFolder(path) self.ui.subType_comboBox.clear() i = 0 index = 0 for each in subTypes : self.ui.subType_comboBox.addItem(each) if each == crSubType : index = i i += 1 self.ui.subType_comboBox.setCurrentIndex(index)
def listAssetUI(self) : crAsset = str() if self.info : crAsset = self.info['assetName'] project = str(self.ui.project_comboBox.currentText()) selType = str(self.ui.type_comboBox.currentText()) selSubType = str(self.ui.subType_comboBox.currentText()) path = '%s%s/asset/3D/%s/%s' % (self.drive, project, selType, selSubType) assets = fileUtils.listFolder(path) self.ui.asset_comboBox.clear() index = 0 i = 0 for each in assets : self.ui.asset_comboBox.addItem(each) if each == crAsset : index = i i += 1 self.ui.asset_comboBox.setCurrentIndex(index)
def manageCacheData(self, action) : logger.debug('def manageCacheData') increment = self.ui.increment_checkBox.isChecked() path = self.getCachePathInfo(increment) if action == 'view' : logger.debug(' - action %s' % action) cachePath = path['cacheDir'] logger.debug(cachePath) if os.path.exists(cachePath) : subprocess.Popen(r'explorer /e,"%s"' % cachePath.replace('/', '\\')) else : self.messageBox('Path not exists', '%s not exists' % cachePath) if action == 'clearAll' : logger.debug(' - action %s'% action) cachePath = path['cacheDir'] if os.path.exists(cachePath) : dirs = fileUtils.listFolder(cachePath) logger.debug(' - %s' % dirs) if dirs : for eachDir in dirs : removeDir = '%s/%s' % (cachePath, eachDir) shutil.rmtree(removeDir) logger.info('Remove %s' % removeDir) self.messageBox('Success', 'All caches data removed') else : self.messageBox('Warning', 'No cache data to remove')
def manageCacheData(self, action): logger.debug('def manageCacheData') increment = self.ui.increment_checkBox.isChecked() path = self.getCachePathInfo(increment) if action == 'view': logger.debug(' - action %s' % action) cachePath = path['cacheDir'] logger.debug(cachePath) if os.path.exists(cachePath): subprocess.Popen(r'explorer /e,"%s"' % cachePath.replace('/', '\\')) else: self.messageBox('Path not exists', '%s not exists' % cachePath) if action == 'clearAll': logger.debug(' - action %s' % action) cachePath = path['cacheDir'] if os.path.exists(cachePath): dirs = fileUtils.listFolder(cachePath) logger.debug(' - %s' % dirs) if dirs: for eachDir in dirs: removeDir = '%s/%s' % (cachePath, eachDir) shutil.rmtree(removeDir) logger.info('Remove %s' % removeDir) self.messageBox('Success', 'All caches data removed') else: self.messageBox('Warning', 'No cache data to remove')
def setPathUI(self, path) : if os.path.exists(path) : self.setLabel(True) dirs = fileUtils.listFolder(path) else : self.setLabel(False) logger.info('%s not exists' % path)
def getProjectList(self) : sgProjects = sgUtils.sgGetProjects() svProjects = fileUtils.listFolder(self.server) projects = dict() for each in sgProjects : projName = each['name'] for eachFilter in self.projectFilters : if eachFilter in projName and projName in svProjects : projects.update({projName: {'type': 'Project', 'id': each['id']}}) return projects
def setRes(self, path): res = fileUtils.listFolder(path) self.ui.renderRes_comboBox.clear() self.ui.animRes_comboBox.clear() if res: self.ui.render_pushButton.setEnabled(True) self.ui.anim_pushButton.setEnabled(True) i = 0 for each in res: self.ui.renderRes_comboBox.addItem(each) self.ui.animRes_comboBox.addItem(each) i += 1 self.ui.renderRes_comboBox.setCurrentIndex(i - 1)
def setRes(self, path) : res = fileUtils.listFolder(path) self.ui.renderRes_comboBox.clear() self.ui.animRes_comboBox.clear() if res : self.ui.render_pushButton.setEnabled(True) self.ui.anim_pushButton.setEnabled(True) i = 0 for each in res : self.ui.renderRes_comboBox.addItem(each) self.ui.animRes_comboBox.addItem(each) i += 1 self.ui.renderRes_comboBox.setCurrentIndex(i-1)
def doCopyTexture(self) : src = self.textureTemplate dst = self.texturePath res = fileUtils.listFolder(src) if os.path.exists(dst) : try : for each in res : src2 = '%s/%s' % (src, each) dst2 = '%s/%s' % (dst, each) result = fileUtils.copyTree(src2, dst2) print result self.messageBox('Complete', 'Copy Texture Complete') except Exception as e : print e self.messageBox('Error', str(e))
def doCopyTexture(self): src = self.textureTemplate dst = self.texturePath res = fileUtils.listFolder(src) if os.path.exists(dst): try: for each in res: src2 = '%s/%s' % (src, each) dst2 = '%s/%s' % (dst, each) result = fileUtils.copyTree(src2, dst2) print result self.messageBox('Complete', 'Copy Texture Complete') except Exception as e: print e self.messageBox('Error', str(e))
def setProjectUI(self) : crProject = str() if self.info : crProject = self.info['projectName'] projects = fileUtils.listFolder(self.drive) self.ui.project_comboBox.clear() index = 0 i = 0 for each in projects : if not each[0] in self.projectSkipKey and each.split('_')[0] in self.projectPrefix : self.ui.project_comboBox.addItem(each) if each == crProject : index = i i += 1 self.ui.project_comboBox.setCurrentIndex(index)
def findVersion(cachePath, increment): dirs = fileUtils.listFolder(cachePath) versions = [] for eachDir in dirs: if eachDir[0] == "v" and eachDir[1:].isdigit(): intVersion = int(eachDir.replace("v", "")) versions.append(intVersion) if versions: maxVersion = sorted(versions)[-1] nextVersion = maxVersion if increment: nextVersion = maxVersion + 1 strVersion = "v%03d" % nextVersion else: strVersion = "v001" return strVersion
def findVersion(cachePath, increment): dirs = fileUtils.listFolder(cachePath) versions = [] for eachDir in dirs: if eachDir[0] == 'v' and eachDir[1:].isdigit(): intVersion = int(eachDir.replace('v', '')) versions.append(intVersion) if versions: maxVersion = sorted(versions)[-1] nextVersion = maxVersion if increment: nextVersion = maxVersion + 1 strVersion = 'v%03d' % nextVersion else: strVersion = 'v001' return strVersion
def setProjectUI(self): crProject = str() if self.info: crProject = self.info['projectName'] projects = fileUtils.listFolder(self.drive) self.ui.project_comboBox.clear() index = 0 i = 0 for each in projects: if not each[0] in self.projectSkipKey and each.split( '_')[0] in self.projectPrefix: self.ui.project_comboBox.addItem(each) if each == crProject: index = i i += 1 self.ui.project_comboBox.setCurrentIndex(index)
def setTypeUI(self): crType = str() if self.info: crType = self.info['assetType'] project = str(self.ui.project_comboBox.currentText()) path = '%s%s/asset/3D' % (self.drive, project) types = fileUtils.listFolder(path) self.ui.type_comboBox.clear() index = 0 i = 0 for each in types: self.ui.type_comboBox.addItem(each) if crType == each: index = i i += 1 self.ui.type_comboBox.setCurrentIndex(index)
def setTypeUI(self) : crType = str() if self.info : crType = self.info['assetType'] project = str(self.ui.project_comboBox.currentText()) path = '%s%s/asset/3D' % (self.drive, project) types = fileUtils.listFolder(path) self.ui.type_comboBox.clear() index = 0 i = 0 for each in types : self.ui.type_comboBox.addItem(each) if crType == each : index = i i += 1 self.ui.type_comboBox.setCurrentIndex(index)