def __init__(self):
     self.Prj = Get.Get().GetActiveProject()  #~ 项目名
     self.ServerRoot = Path.Path().GetServerPath()  #~ 服务器地址
     self.LocalRoot = Path.Path().GetLocalPath()  #~ 本地地址
     self.alLayerShadersInformation = {}  #~ alLayer连接的两个材质球信息,用于手动赋予材质
     self.erroCollecterList = []  #~ 错误信息收集列表
     self.showUploadWindows()
 def __init__(self):
     self.getNamespace()
     ServerRoot = Path.Path().GetServerPath()
     LocalRoot = Path.Path().GetLocalPath()
     Prj = Get.Get().GetActiveProject()
     #//hnas01/data/Projects/DragonNest2/
     self.ServerRootPath = ServerRoot+'/'+Prj+'/'+'Rigs'+'/'+'HugePropsSets'+'/'
     self.LocalRootPath = LocalRoot+'/'+Prj+'/'+'Rigs'+'/'+'HugePropsSets'+'/'
     self.ServerFilePath = ServerRoot+'/'+Prj+'/'+'Rigs'+'/'+'Props'+'/'
Exemple #3
0
    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 filePathTranslate(self,local=None,server=None):
     '''
     转换服务器地址和本地地址
     '''
     self.ServerRoot = Path.Path().GetServerPath()  #~ 服务器地址
     self.LocalRoot = Path.Path().GetLocalPath()    #~ 本地地址
     if local != None and server == None:
         #~ 将本地地址换成服务器地址
         result = local.replace(self.LocalRoot,self.ServerRoot)
     elif local == None and server != None:
         #~ 将服务器地址换成本地地址
         result = server.replace(self.ServerRoot,self.LocalRoot)
     else:
         result = None
     return result
Exemple #5
0
 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 getFilePath(self):
        #ServerProjectsPath\%ProjectName%\Rigs\%Type%\%Name%\TDAssets\
        Prj = Get.Get().GetActiveProject()
        ServerRoot = Path.Path().GetServerPath()

        allGroup = cmds.ls(type='transform')
        keyGroup = []
        for item in allGroup:
            test = item.split('_')
            if test[-1] == 'GRP' and test[-2] == 'model':
                keyGroup.append(item)
        try:
            tmp_modType = cmds.getAttr(keyGroup[0] + '.Type')
            keyName = cmds.getAttr(keyGroup[0] + '.treeName')
        except:
            #cmds.confirmDialog(title='Oops', message='Plsase open your Rig file first!', button='Gotcha')
            cmds.textField('textServer',
                           text=u'请打开绑定文件,再重新打开此插件,以获取上传路径',
                           edit=True)
            return
        if tmp_modType == 'c':
            modType = 'Characters'
        elif tmp_modType == 'p':
            modType = 'Props'
        else:
            print 'Erro modType:%s' % tmp_modType

        self.ServerRootPath = '%s/%s/Rigs/%s/%s/TDAssets/' % (
            ServerRoot, Prj, modType, keyName
        )  #'ServerProjectsPath/%ProjectName%/Rigs/%Type%/%Name%/TDAssets'
        #print self.ServerRootPath
        textServer = self.ServerRootPath.replace('/', '\\')
        cmds.textField('textServer', text=textServer, edit=True)
Exemple #7
0
    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()
Exemple #8
0
    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 __init__(self, env=None):
        super(TDsCodeUpload, self).__init__()
        self.env = env
        self.image_path = IMAGEPATH
        if self.env == "maya.exe":
            import Mili.Module.utilties.MiliUser as MiliUser
            import Mili.Module.utilties.lsrunas as lsrunas
            import Mili.Module.utilties.Get as Get
            import Mili.Module.utilties.Path as Path
            reload(lsrunas)
            reload(MiliUser)
            reload(Get)
            reload(Path)

            self.department = MiliUser.MiliUser()['department']
            self.appointment = MiliUser.MiliUser()['appointment']
            self.moduleList = MiliUser.MiliUser().getGroupList()
            self.project = Get.Get().GetActiveProject()
            self.projectList = []
            self.LocalRoot = Path.Path().GetLocalPath()
            self.ServerRoot = Path.Path().GetServerPath()
            listDir = os.listdir('%s/' % self.ServerRoot)
            for item in listDir:
                testList = item.split('.')
                if len(testList) == 1:
                    if testList[0] == 'backUp':
                        pass
                    else:
                        self.projectList.append(item)
        else:
            self.department = DEPARTMENT
            self.appointment = APPOINTMENT
            self.project = PROJECT
            self.moduleList = eval(MODULELIST)
            self.projectList = eval(PROJECTLIST)
            self.LocalRoot = LOCALROOTPATH
            self.ServerRoot = SERVERROOTPATH

        self.showWindows()
        self.setInitValue()
        self.setUserRights()
 def __init__(self):
     Prj = Get.Get().GetActiveProject()
     LocalRootPath = Path.Path().GetLocalPath() + '/' + Prj + '/'  #~ 本地的根地址
     ServerRootPath = Path.Path().GetServerPath() + '/'  #~ 服务器地址
     tmp_current_time = str(datetime.datetime.now())
     self.date = tmp_current_time.split(' ')[0]
     self.filename = cmds.file(q=True, expandName=True).split('/')[-1]
     self.movPath = ''
     self.originalFilePath = cmds.file(q=True,
                                       expandName=True)  #~ 原始maya文件地址
     self.LocalFilePath = LocalRootPath + "Backup/"  #~ 本地拷贝的maya文件的路径,用于lsrunas上传类
     """遍历出服务器maya文件地址"""
     parts = self.originalFilePath.split('/')
     for i in range(2, len(parts) - 1):
         ServerRootPath += parts[i]
         ServerRootPath += '/'
     self.ServerBackupPath = ServerRootPath + 'Playblast/' + self.date + '/'  #~ 服务器maya文件路径,用于lsrunas上传类
     self.LocalPlayblastPath = self.movPath  #~ 本地拍屏文件路径,用于lsrunas上传类
     self.ServerRootPath = ProjectConfig.ProjectConfig().get(
         'PlayblastEditRoot',  #~ 服务器剪辑目录路径,用于lsrunas上传类
         default='//hnas01/Data/Edit/%s/AutoImport/' % Prj)
Exemple #11
0
    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)
Exemple #12
0
    def backUpFunc(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)

        ids = cmds.iconTextRadioCollection('historyCodeList',
                                           select=True,
                                           q=True)
        try:
            backup_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

        codeName = backup_codeName.split('&')[-1]
        file = open(ServerBackUpPath + backup_codeName, 'r').read()
        cmds.textField('showTextName',
                       enable=self.flag[4],
                       text=codeName,
                       edit=True)
        cmds.scrollField('showText',
                         enable=self.flag[3],
                         text=file.decode('utf-8'),
                         edit=True)
        self.textOldFileName = codeName
        cmds.deleteUI('backUpWindow')
Exemple #13
0
 def projectMenuItem(self):
     Prj = Get.Get().GetActiveProject()
     ServerRoot = Path.Path().GetServerPath()
     listDir = os.listdir('%s/' % ServerRoot)
     projectList = []
     for item in listDir:
         testList = item.split('.')
         if len(testList) == 1:
             if testList[0] == 'backUp':
                 pass
             else:
                 projectList.append(item)
         else:
             pass
     for i in range(len(projectList)):
         if projectList[i] == Prj:
             tmp = projectList[0]
             projectList[0] = projectList[i]
             projectList[i] = tmp
     for item in projectList:
         cmds.menuItem(label=item)
     return projectList
    def assignedTo(self):

        redmine = Redmine('http://192.168.100.4/redmine/',
                          key='fb77dd01d1c51f56596f5e3a36fcfc5f1f77d16f')
        users = redmine.user.all()
        profileDir = Path.Path().GetServerPath() + '/TeamConfig'
        MiliWork = {}
        if os.path.isdir(profileDir):
            for i in os.listdir(profileDir):
                name, ext = os.path.splitext(i)
                if ext == '.miliProfile':
                    tmpAccount = MiliUser.MiliUser(userName=name)
                    MiliWork[name] = tmpAccount['department']
        self.pipelineTDs = {}
        for user in users:
            userLogin = user['_attributes']['login']
            userID = user['_attributes']['id']
            if userLogin in list(
                    MiliWork.keys()) and MiliWork[userLogin] == 'PipelineTD':
                tmpMap = {'userID': userID, 'userLogin': userLogin}
                self.pipelineTDs[str(user).decode('utf-8')] = tmpMap
                #print userID,userLogin,user
        for item in list(self.pipelineTDs.keys()):
            self.assigned.addItem(item)
Exemple #15
0
    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()
Exemple #16
0
    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)
Exemple #17
0
    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
Exemple #18
0
    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)
Exemple #19
0
    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