def deleteCode(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] ServerRoot = Path.Path().GetServerPath() ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( ServerRoot, project, module) ids = cmds.iconTextRadioCollection('pythonCodeList', select=True, q=True) try: codeName = cmds.iconTextRadioButton(ids, label=True, q=True) except RuntimeError: sys.exit() except IOError: sys.exit() yourChoice = cmds.confirmDialog( title='CLOSED', message='You sure you want to delete the code?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if yourChoice == 'Yes': lsrunas.lsrunas().deleteFile(ServerRootPath + codeName) cmds.textField('showTextName', text='', e=True) cmds.scrollField('showText', text='', e=True) else: print 'Wise choise' time.sleep(2) self.scrollMenuReflesh()
def uploadServer(self): flag = self.fileUploadComboBox.currentText() if flag == u'请设置*': self.dialogUI(u'请设置是否上传错误文件!') return False elif flag == u'不上传': return True else: tmp1_current_time = str(datetime.datetime.now()) tmp2_current_time = tmp1_current_time.replace(' ', '_') tmp3_current_time = tmp2_current_time.split('.') tmp4_current_time = tmp3_current_time[0].split(':') current_time = tmp4_current_time[0] + '-' + tmp4_current_time[ 1] + '-' + tmp4_current_time[2] sceneNameLongPath = cmds.file(q=True, sceneName=True) sceneName = sceneNameLongPath.split('/')[-1] self.ServerRootPath = '//hnas02/project_backup/RedmineErroReport/%s/%s' % ( current_time, sceneName) self.LocalRootPath = sceneNameLongPath tmp = self.description.toPlainText( ) + '\n' + u'报错文件地址 : %s' % self.ServerRootPath.replace('/', '\\') self.description.setText(tmp) uploadTime = time.time() if not os.path.isdir(os.path.dirname(self.ServerRootPath)): lsrunas.lsrunas().CreateDir_1( os.path.dirname(self.ServerRootPath)) lsrunas.lsrunas(uploadTime).UploadFile(self.LocalRootPath, self.ServerRootPath, DeleteSource=False) return True
def backUpAllFileGui(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] ServerRoot = Path.Path().GetServerPath() ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/backup/' % ( ServerRoot, project, module) if os.path.isdir(ServerRootPath): pass else: lsrunas.lsrunas().CreateDir_1(ServerRootPath) listAllDir = os.listdir(ServerRootPath) listAllDir.sort() if cmds.window('backUpAllFileWindow', q=1, exists=1): cmds.deleteUI('backUpAllFileWindow') backUpAllFileWindow = cmds.window('backUpAllFileWindow', title='Backup', widthHeight=(300, 300), sizeable=False) cmds.rowColumnLayout('backUpAllLayout', numberOfColumns=1, columnWidth=[(1, 300)]) cmds.text('History All Code Backuper', height=30, backgroundColor=[0.5, 0.6, 0.6]) cmds.separator(style='out') cmds.text(' ') cmds.text(' ') cmds.separator(style='out') cmds.text(label='All Code`s History:', align='left') cmds.text(' ') cmds.scrollLayout('historyAllScrollLayout', parent='backUpAllLayout', width=300, height=400) cmds.iconTextRadioCollection('historyAllCodeList') for i in range(len(listAllDir)): cmds.iconTextRadioButton(listAllDir[i], collection='historyAllCodeList', st='iconAndTextHorizontal', visible=True, l=listAllDir[i], width=270, height=25) cmds.separator(style='out') cmds.setParent('..') cmds.text(' ') cmds.button(label='BackUp', height=30, command=lambda *arg: self.backUpAllFunc()) cmds.text(' ') cmds.showWindow(backUpAllFileWindow)
def activeCode(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] LocalRoot = Path.Path().GetLocalPath() ServerRoot = Path.Path().GetServerPath() LocalRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( LocalRoot, project, module) ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( ServerRoot, project, module) uploadTime = time.time() if os.path.isdir(ServerRootPath): pass else: lsrunas.lsrunas().CreateDir_1(ServerRootPath) if os.path.isdir(LocalRootPath): pass else: os.makedirs(LocalRootPath) #do active code,read and write the map if os.path.isfile(ServerRootPath + 'activeMap.txt'): file = open(ServerRootPath + 'activeMap.txt', 'rb') activeMap = json.load(file) file.close() else: activeMap = {} self.changeCheckBoxMark() for key in list(self.changeBoxMap.keys()): value = self.changeBoxMap[key] activeMap[key] = [value] print(activeMap) file = open(LocalRootPath + 'activeMap.txt', 'wb') json.dump(activeMap, file) file.close() lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath + 'activeMap.txt', ServerRootPath + 'activeMap.txt', DeleteSource=False) cmds.confirmDialog(title='Good Job', message='Active completed!', button='Gotcha') #refresh oldActiveMap`s values file = open(ServerRootPath + 'activeMap.txt', 'rb') activeMap = json.load(file) file.close() for i in range(self.id + 1): key = cmds.iconTextRadioButton('id%s' % i, l=True, q=True) mapValue = activeMap[key][0] self.oldActiveMap[key] = mapValue
def remove(self): tmp1_current_time = str(datetime.datetime.now()) tmp2_current_time = tmp1_current_time.replace(' ', '_') tmp3_current_time = tmp2_current_time.split('.') tmp4_current_time = tmp3_current_time[0].split(':') current_time = tmp4_current_time[0] + '-' + tmp4_current_time[ 1] + '-' + tmp4_current_time[2] ids = cmds.iconTextRadioCollection('hugePropsIconTextRadioCollection', select=True, q=True) try: hugePropsName = cmds.iconTextRadioButton(ids, label=True, q=True) except RuntimeError: return fileName = hugePropsName + '_' + current_time + '.json' LocalRootPath = self.LocalRootPath + hugePropsName + '/' + fileName ServerRootPath = self.ServerRootPath + hugePropsName + '/' + fileName try: file = open(ServerRootPath, 'rb') informationMapList = json.load(file) file.close() except IOError: allFileList = os.listdir(self.ServerRootPath + hugePropsName) fileName = sorted(allFileList)[-1] ServerRootPath = self.ServerRootPath + hugePropsName + '/' + fileName file = open(ServerRootPath, 'rb') informationMapList = json.load(file) file.close() try: parts = cmds.iconTextRadioCollection('keyIconTextRadioCollection', select=True, q=True).split(':') ctrlCircle = parts[1] + ':' + parts[2] except IndexError: return for info in informationMapList: if info['ctrlCircle'] == ctrlCircle: informationMapList.remove(info) for info in informationMapList: print info['name'] file = open(LocalRootPath, 'wb') json.dump(informationMapList, file) file.close() uploadTime = time.time() if not os.path.isdir( os.path.dirname(self.ServerRootPath + hugePropsName)): lsrunas.lsrunas().CreateDir_1( os.path.dirname(self.ServerRootPath + hugePropsName)) lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath, ServerRootPath, DeleteSource=False) self.refreshPropsList()
def lsrunasPlus(self,ServerPath,LocalPath=None,filename=None,onlyCreate=False): ''' 创建文件路径,上传文件的方法函数 ''' uploadTime = time.time() if LocalPath==None or os.path.isdir(LocalPath): pass else: os.makedirs(LocalPath) if not os.path.isdir(os.path.dirname(ServerPath)): lsrunas.lsrunas().CreateDir_1(os.path.dirname(ServerPath)) if onlyCreate == False: lsrunas.lsrunas(uploadTime).UploadFile(LocalPath+filename,ServerPath+filename,DeleteSource=False)
def __init__(self,shot): self.shot = shot exportTime = time.time() tmpTime = time.localtime(exportTime) self.dateStr = '%0.4d_%0.2d_%0.2d'%(tmpTime.tm_year, tmpTime.tm_mon, tmpTime.tm_mday) self.localPath = Path.Path().GetLocalPath()+'/'+Get.Get().GetActiveProject()+'/FarmBatch/'+self.dateStr+'/'+self.shot+'/' self.serverPath = lsrunas.lsrunas().Mili_Back_Root+'/'+Get.Get().GetActiveProject()+'/FarmBatch/'+self.dateStr+'/'+self.shot+'/'
def Upload(self): hugePropsName = cmds.textField('Huge_Props_Name',text=True,q=True) if hugePropsName == '': ids = cmds.iconTextRadioCollection('hugePropsIconTextRadioCollection', select=True, q=True) hugePropsName = cmds.iconTextRadioButton(ids,label=True,q=True) allFileList = os.listdir(self.LocalRootPath+hugePropsName) fileName = sorted(allFileList)[-1] ServerRootPath = self.ServerRootPath+hugePropsName+'/'+fileName LocalRootPath = self.LocalRootPath+hugePropsName+'/'+fileName uploadTime = time.time() if not os.path.isdir(os.path.dirname(self.ServerRootPath+hugePropsName)): lsrunas.lsrunas().CreateDir_1(os.path.dirname(self.ServerRootPath+hugePropsName)) lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath, ServerRootPath, DeleteSource=False) flag = cmds.textField('Huge_Props_Name',text=True,q=True) if flag != '': self.refreshHugePropsListPlus() cmds.confirmDialog(title=u'完成', message=u'上传完成!', button=u'好的')
def uploadFile(self): if cmds.file(q=True, sceneName=True) == '': cmds.confirmDialog(title='Oops', message='Plsase open your file!', button='Gotcha') sys.exit() else: self.fileName = cmds.file(q=True, expandName=True).split('/')[-1] self.filePath = cmds.file(q=True, expandName=True) LocalRootPath = self.filePath uploadTime = time.time() if self.ServerRootPath == '': cmds.confirmDialog(title='Oops', message='Please open rig file first!', button='Gotcha') sys.exit() elif os.path.isfile(self.ServerRootPath + self.fileName): lsrunas.lsrunas().deleteFile(self.ServerRootPath + self.fileName) time.sleep(3) else: pass if not os.path.isdir(os.path.dirname(self.ServerRootPath)): lsrunas.lsrunas().CreateDir_1(os.path.dirname(self.ServerRootPath)) print LocalRootPath print self.ServerRootPath + self.fileName lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath, self.ServerRootPath + self.fileName, DeleteSource=False) cmds.confirmDialog(title='DONE', message='Job Done!!!', button='Gotcha')
def historyCopy(self, argName, argLocalPath): tmp1_current_time = str(datetime.datetime.now()) tmp2_current_time = tmp1_current_time.replace(' ', '_') tmp3_current_time = tmp2_current_time.split('.') tmp4_current_time = tmp3_current_time[0].split(':') current_time = tmp4_current_time[0] + '-' + tmp4_current_time[ 1] + '-' + tmp4_current_time[2] name = current_time + '&' + argName projectList = self.jobList[0] moduleList = self.jobList[1] projectOption = cmds.optionMenu('optionProject', q=True, select=True) moduleOption = cmds.optionMenu('optionModule', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] LocalRoot = Path.Path().GetLocalPath() ServerRoot = Path.Path().GetServerPath() LocalRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/backup/' % ( LocalRoot, project, module) ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/backup/' % ( ServerRoot, project, module) uploadTime = time.time() if os.path.isdir(ServerRootPath): pass else: lsrunas.lsrunas().CreateDir_1(ServerRootPath) if os.path.isdir(LocalRootPath): pass else: os.makedirs(LocalRootPath) shutil.copy2(argLocalPath + argName, LocalRootPath + name) lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath + name, ServerRootPath + name, DeleteSource=False)
def lsrunasPlus(self, local, server, name=None, delete=False): if self.env == "maya.exe": import Mili.Module.utilties.lsrunas as lsrunas reload(lsrunas) if not os.path.isdir(server): lsrunas.lsrunas().CreateDir_1(server) if delete == True: lsrunas.lsrunas().deleteFile(server + name) else: lsrunas.lsrunas(time.time()).UploadFile(local + name, server + name, DeleteSource=False) else: import shutil if not os.path.isdir(server): os.makedirs(server) if not os.path.isdir(server): os.makedirs(server) if delete == True: os.remove(server + name) else: shutil.copyfile(local + name, server + name)
def uploadTheFile(self): if os.path.isdir(self.LocalFilePath): pass else: os.makedirs(self.LocalFilePath) if cmds.file(q=True, sceneName=True) == '': #~ 判断是否为空文件 cmds.confirmDialog(title='Oops', message='Plsase open your file!', button='Get it') sys.exit() yourChoice = cmds.confirmDialog(title=u'上传文件', message=u'是否选择提交拍屏 ?', button=[u'提交', u'不要'], defaultButton=u'提交', cancelButton=u'不要', dismissString=u'不要') if yourChoice == u'提交': self.ServerPlayblastPath = self.submit() #~ 登记信息 uploadTime = time.time() """copy文件到项目的Backup文件夹""" shutil.copyfile(self.originalFilePath, self.LocalFilePath + self.filename) """上传maya文件""" if not os.path.isdir(os.path.dirname(self.ServerBackupPath)): lsrunas.lsrunas().CreateDir_1( os.path.dirname(self.ServerBackupPath)) lsrunas.lsrunas(uploadTime).UploadFile( self.LocalFilePath + self.filename, self.ServerBackupPath + self.filename, DeleteSource=False) """上传拍屏文件到剪辑目录""" if not os.path.isdir(os.path.dirname(self.ServerPlayblastPath)): lsrunas.lsrunas().CreateDir_1( os.path.dirname(self.ServerPlayblastPath)) lsrunas.lsrunas(uploadTime).UploadFile( self.LocalPlayblastPath + self.playblastFile, self.ServerPlayblastPath + self.playblastFile, DeleteSource=False) """上传拍屏文件到项目目录""" if not os.path.isdir(os.path.dirname(self.ServerBackupPath)): lsrunas.lsrunas().CreateDir_1( os.path.dirname(self.ServerBackupPath)) lsrunas.lsrunas(uploadTime).UploadFile( self.LocalPlayblastPath + self.playblastFile, self.ServerBackupPath + self.playblastFile, DeleteSource=False) else: print 'Wise choice' cmds.confirmDialog(title='Job Done', message='The video has uploaded to the server', button='Get it!')
def fileWork(self, fileItem, texSize, texSizeArg): ''' 将所有的文件路径都换到三十二分之一的位置 ''' #get file path try: tmp0_filePath = cmds.getAttr(fileItem + '.fileTextureName') tmp_filePath = self.globUdim(tmp0_filePath) except: self.erroRaise() return filePathList = tmp_filePath.split('/') if len(filePathList) < 6: return if filePathList[2] == 'hnas01' or filePathList[3] == 'data': #filePath = '//hnas01/data/Projects/PPR/Textures/Characters/bitly/Head_clr.jpg' filePath = '%s/%s/%s/%s/%s/%s/%s' % ( self.ServerRoot, self.Prj, filePathList[6], filePathList[7], filePathList[8], texSize, filePathList[-1]) elif filePathList[0] == 'D:': #filePath = 'D:/Projects/PPR/Textures/Characters/bitly/Head_clr.jpg' if filePathList[6] == texSize: filePath = '%s/%s/%s/%s/%s/%s/%s' % ( self.ServerRoot, self.Prj, filePathList[3], filePathList[4], filePathList[5], texSize, filePathList[-1]) else: filePath = '%s/%s/%s/%s/%s/%s/%s' % ( self.ServerRoot, self.Prj, filePathList[3], filePathList[4], filePathList[5], texSize, filePathList[-1]) else: pass keyFilePath = filePath.split('/') imageFilePath = '%s/%s/%s/%s/%s/%s' % (self.ServerRoot, self.Prj, keyFilePath[6], keyFilePath[7], keyFilePath[8], keyFilePath[-1]) ServerFilePath = '%s/%s/%s/%s/%s/%s/%s' % ( self.ServerRoot, self.Prj, keyFilePath[6], keyFilePath[7], keyFilePath[8], keyFilePath[9], keyFilePath[-1]) #D:\Projects\RobRabbit_Test\Textures\Characters\bitly\Half\.jpg myLocalFilePath = '%s/%s/%s/%s/%s/%s/%s' % ( self.LocalRoot, keyFilePath[5], keyFilePath[6], keyFilePath[7], keyFilePath[8], keyFilePath[9], keyFilePath[-1]) ############################################## #上传服务器 #~ make sure that the texture is new and create low size texture if os.path.exists(ServerFilePath): try: lowTexTime = os.path.getmtime(ServerFilePath) highTexTime = os.path.getmtime(imageFilePath) except: self.erroRaise() else: lowTexTime = 0.0 highTexTime = 0.0 if os.path.exists(ServerFilePath) and str(lowTexTime) == str( highTexTime): pass else: tmpCmd = 'imconvert.exe "%s" -resize %s%% "%s"' % ( imageFilePath, 100 * float(texSizeArg), myLocalFilePath) os.popen(tmpCmd) targetDir = '%s/%s/%s/%s/%s/%s' % (self.LocalRoot, keyFilePath[5], keyFilePath[6], keyFilePath[7], keyFilePath[8], keyFilePath[9]) itemName = keyFilePath[-1] try: origTime = os.path.getmtime(imageFilePath) except WindowsError: self.erroRaise() if not os.path.isdir(targetDir): os.makedirs(targetDir) try: os.utime(targetDir + '/' + itemName, (origTime, origTime)) except: self.erroRaise() uploadTime = time.time() if not os.path.isdir(os.path.dirname(ServerFilePath)): lsrunas.lsrunas().CreateDir_1(os.path.dirname(ServerFilePath)) try: lsrunas.lsrunas(uploadTime).UploadFile(myLocalFilePath, ServerFilePath, DeleteSource=False) except RuntimeError: self.erroRaise() ################################################ #~ change file path to low texture cmds.setAttr(fileItem + '.fileTextureName', ServerFilePath, type='string')
def updateCode(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] LocalRoot = Path.Path().GetLocalPath() ServerRoot = Path.Path().GetServerPath() LocalRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( LocalRoot, project, module) ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( ServerRoot, project, module) uploadTime = time.time() if os.path.isdir(ServerRootPath): pass else: lsrunas.lsrunas().CreateDir_1(ServerRootPath) if os.path.isdir(LocalRootPath): pass else: os.makedirs(LocalRootPath) try: tmp_codeName = cmds.textField('showTextName', text=True, q=True) codeNameContent = cmds.scrollField('showText', text=True, q=True) codeNameList = tmp_codeName.split('.') codeName = codeNameList[0] + '.py' except RuntimeError: cmds.confirmDialog(title='Oops', message='Your code`s name is empty!', button='Gotcha') file = open(LocalRootPath + codeName, 'w') file.writelines(codeNameContent) file.close() lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath + codeName, ServerRootPath + codeName, DeleteSource=False) if self.textOldFileName == codeName: pass else: lsrunas.lsrunas().deleteFile(ServerRootPath + self.textOldFileName) time.sleep(2) #refresh activeMap file = open(ServerRootPath + 'activeMap.txt', 'rb') activeMap = json.load(file) file.close() oldKey = self.textOldFileName key = codeName value = activeMap[oldKey][0] activeMap[key] = [value] self.oldActiveMap[key] = value if not oldKey == key: #del activeMap[oldKey] del self.oldActiveMap[oldKey] else: pass file = open(LocalRootPath + 'activeMap.txt', 'wb') json.dump(activeMap, file) file.close() lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath + 'activeMap.txt', ServerRootPath + 'activeMap.txt', DeleteSource=False) self.scrollMenuReflesh() cmds.textField('showTextName', text='', e=True) cmds.scrollField('showText', text='', e=True) cmds.confirmDialog(title='Good Job', message='Update completed!', button='Gotcha') if not codeName == '': self.historyCopy(codeName, LocalRootPath) else: pass
def backUpAllFunc(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] ServerRoot = Path.Path().GetServerPath() LocalRoot = Path.Path().GetLocalPath() ServerBackUpPath = '%s/%s/ProjectConfig/workNodeScripts/%s/backup/' % ( ServerRoot, project, module) LocalRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( LocalRoot, project, module) ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( ServerRoot, project, module) uploadTime = time.time() ids = cmds.iconTextRadioCollection('historyAllCodeList', select=True, q=True) try: backupAll_codeName = cmds.iconTextRadioButton(ids, label=True, q=True) except RuntimeError: cmds.confirmDialog(title='Erro', message='Please select a file first!', button='Gotcha') sys.exit() pass file = open(ServerRootPath + 'activeMap.txt', 'rb') activeMap = json.load(file) file.close() name = backupAll_codeName.split('&')[-1] if os.path.isfile(ServerRootPath + name): cmds.confirmDialog( title='Oops', message='The name has existed, you can`t backup your code!', button='Gotcha') sys.exit() else: file = open(ServerBackUpPath + backupAll_codeName, 'r') copyText = file.readlines() file.close() file = open(LocalRootPath + name, 'w') file.writelines(copyText) file.close() lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath + name, ServerRootPath + name, DeleteSource=False) #activeMap[name] = [Active,Share] activeMap[name] = [True, False] file = open(LocalRootPath + 'activeMap.txt', 'wb') json.dump(activeMap, file) file.close() if not os.path.isdir(os.path.dirname(ServerRootPath)): lsrunas.lsrunas().CreateDir_1(os.path.dirname(ServerRootPath)) lsrunas.lsrunas(uploadTime).UploadFile( LocalRootPath + 'activeMap.txt', ServerRootPath + 'activeMap.txt', DeleteSource=False) self.historyCopy(name, LocalRootPath) file = open(ServerBackUpPath + backupAll_codeName, 'r').read() cmds.textField('showTextName', enable=self.flag[4], text=name, edit=True) cmds.scrollField('showText', enable=self.flag[3], text=file.decode('utf-8'), edit=True) self.textOldFileName = name cmds.deleteUI('backUpAllFileWindow') self.scrollMenuReflesh()
def codeUpload(self): projectList = self.jobList[0] moduleList = self.jobList[1] projectOption = cmds.optionMenu('optionProject', q=True, select=True) moduleOption = cmds.optionMenu('optionModule', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] fileName = cmds.textField('codeName', q=True, text=True) copyText = cmds.scrollField('copyText', q=True, text=True) name = fileName LocalRoot = Path.Path().GetLocalPath() ServerRoot = Path.Path().GetServerPath() LocalRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( LocalRoot, project, module) ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( ServerRoot, project, module) uploadTime = time.time() try: file = open(ServerRootPath + 'activeMap.txt', 'rb') activeMap = json.load(file) file.close() except: activeMap = {} if os.path.isdir(ServerRootPath): pass else: lsrunas.lsrunas().CreateDir_1(ServerRootPath) if os.path.isdir(LocalRootPath): pass else: os.makedirs(LocalRootPath) #upload the copy code if os.path.isfile(ServerRootPath + name): cmds.confirmDialog(title='Oops', message='The name has existed, rename it!', button='Gotcha') return else: file = open(LocalRootPath + name, 'w') file.write(copyText) file.close() lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath + name, ServerRootPath + name, DeleteSource=False) cmds.textField('codeName', text='', edit=True) cmds.scrollField('copyText', text='', edit=True) cmds.confirmDialog(title='Good Job', message='Job Done! \n\n%s' % name, button='Gotcha') """上传activeMap到服务器""" #activeMap[name] = [Active,Share] activeMap[name] = [True, False] file = open(LocalRootPath + 'activeMap.txt', 'wb') json.dump(activeMap, file) file.close() if not os.path.isdir(os.path.dirname(ServerRootPath)): lsrunas.lsrunas().CreateDir_1(os.path.dirname(ServerRootPath)) lsrunas.lsrunas(uploadTime).UploadFile(LocalRootPath + 'activeMap.txt', ServerRootPath + 'activeMap.txt', DeleteSource=False) self.historyCopy(name, LocalRootPath)
def backUpGui(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] ServerRoot = Path.Path().GetServerPath() ServerRootPath = '%s/%s/ProjectConfig/workNodeScripts/%s/backup/' % ( ServerRoot, project, module) ids = cmds.iconTextRadioCollection('pythonCodeList', select=True, q=True) try: codeName = cmds.iconTextRadioButton(ids, label=True, q=True) except RuntimeError: sys.exit() if os.path.isdir(ServerRootPath): pass else: lsrunas.lsrunas().CreateDir_1(ServerRootPath) listAllDir = os.listdir(ServerRootPath) listDir = [] for item in listAllDir: tmp = item.split('&') if tmp[-1] == codeName: listDir.append(item) if cmds.window('backUpWindow', q=1, exists=1): cmds.deleteUI('backUpWindow') backUpWindow = cmds.window('backUpWindow', title='Backup', widthHeight=(300, 300), sizeable=False) cmds.rowColumnLayout('backUpLayout', numberOfColumns=1, columnWidth=[(1, 300)]) cmds.text('History Code Backuper', height=30, backgroundColor=[0.5, 0.6, 0.5]) cmds.separator(style='out') cmds.text(' ') cmds.separator(style='out') cmds.text(' ') cmds.rowColumnLayout(parent='backUpLayout', numberOfColumns=3, columnWidth=[(1, 160), (2, 70), (3, 50)]) cmds.text(label='Share your code with others :', align='left') cmds.checkBox('shareCheckBox', l='Not now', height=25, enable=False, value=False) cmds.button(label='change', command=lambda *arg: self.shareChange()) cmds.setParent('..') cmds.text(' ') cmds.separator(style='out') cmds.text(label='Code`s History:', align='left') cmds.text(' ') cmds.scrollLayout('historyScrollLayout', parent='backUpLayout', width=300, height=120) cmds.iconTextRadioCollection('historyCodeList') for i in range(len(listDir)): cmds.iconTextRadioButton(listDir[i], collection='historyCodeList', st='iconAndTextHorizontal', visible=True, l=listDir[i], width=270, height=25) cmds.separator(style='out') cmds.setParent('..') cmds.text(' ') cmds.button(label='BackUp', height=30, command=lambda *arg: self.backUpFunc()) cmds.text(' ') cmds.showWindow(backUpWindow)
def showCodeList(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] ServerRoot = Path.Path().GetServerPath() pythonCodeFilePath = '%s/%s/ProjectConfig/workNodeScripts/%s/' % ( ServerRoot, project, module) #print pythonCodeFilePath if os.path.isdir(pythonCodeFilePath): pass else: lsrunas.lsrunas().CreateDir_1(pythonCodeFilePath) tmp_listDir = os.listdir(pythonCodeFilePath) listDir = [] for item in tmp_listDir: tmp = item.split('.') if tmp[-1] == 'py' or tmp[-1] == 'mel': listDir.append(item) else: pass cmds.iconTextRadioCollection('pythonCodeList') self.id = -1 for i in range(len(listDir)): self.id += 1 cmds.rowColumnLayout(parent='scrollLayoutUnique', numberOfColumns=4, columnWidth=[(1, 265), (2, 40), (3, 20), (4, 45)]) cmds.iconTextRadioButton('id%s' % i, collection='pythonCodeList', st='iconAndTextHorizontal', visible=True, l=listDir[i], width=350, height=25) cmds.text('active:', enable=False) cmds.checkBox('id%s' % i, l='', height=25, visible=True, value=True) cmds.button(label='...', command=lambda *arg: self.backUpGui()) cmds.setParent('..') #改变文件的列表的checkBox的显示 if len(listDir) == 0: pass else: file = open(pythonCodeFilePath + 'activeMap.txt', 'rb') activeMap = json.load(file) file.close() for i in range(self.id + 1): key = cmds.iconTextRadioButton('id%s' % i, l=True, q=True) try: mapValue = activeMap[key][0] except: mapValue = True cmds.checkBox('id%s' % i, value=bool(mapValue), e=True) self.oldActiveMap[key] = mapValue