def backup( currentPath, serverPath, *args ): backupFolderPath, fileName = getBackupPath( serverPath ) #print "before : ", backupFolderPath+'/'+fileName backupFileName = checkSamePathAndRenamePath( backupFolderPath+'/'+fileName ) if os.path.exists( serverPath ): shutil.copy2( serverPath, backupFileName ) print "from : ", serverPath print "copy to : ", backupFileName serverFolderName, serverFileName = separateFolderAndfile( serverPath ) currentFileName = '' if serverFileName: currentFileName = serverFileName else: currentFileName = 'temp.mb' if not os.path.exists( currentPath ): nowTime = datetime.datetime.now() folderName ='%04d%02d%02d' %( nowTime.year, nowTime.month, nowTime.day ) filePath = model.defaultFileBrowserPath+'/'+folderName+'/'+currentFileName currentPath = checkSamePathAndRenamePath( filePath ) functions.makePath( '/'.join( currentPath.split( '/' )[:-1] ) ) print cmds.file( q=1, sceneName=1 ) cmds.file( rename=currentPath ) cmds.file( save=1 ) if currentPath.replace( '\\', '/' ).strip() == serverPath.replace( '\\', '/' ).strip(): return None shutil.copy2( currentPath, serverPath )
def saveAndUpdate(currentPath, serverPath): backupFolderPath, fileName = getBackupPath(serverPath) #print "before : ", backupFolderPath+'/'+fileName backupFileName = checkSamePathAndRenamePath(backupFolderPath + '/' + fileName) if os.path.exists(serverPath): shutil.copy2(serverPath, backupFileName) print "from : ", serverPath print "copy to : ", backupFileName serverFolderName, serverFileName = separateFolderAndfile(serverPath) currentFileName = '' if serverFileName: currentFileName = serverFileName else: currentFileName = 'temp.mb' if not os.path.exists(currentPath): nowTime = datetime.datetime.now() folderName = '%04d%02d%02d' % (nowTime.year, nowTime.month, nowTime.day) filePath = model.defaultFileBrowserPath + '/' + folderName + '/' + currentFileName currentPath = checkSamePathAndRenamePath(filePath) functions.makePath('/'.join(currentPath.split('/')[:-1])) cmds.file(rename=currentPath) cmds.file(save=1) shutil.copy2(currentPath, serverPath)
def getBackupPath(serverPath): serverSplit = serverPath.replace('\\', '/').split('/') nowTime = datetime.datetime.now() folderName = '%04d%02d%02d' % (nowTime.year, nowTime.month, nowTime.day) backupPath = '/'.join(serverSplit[:-1]) + '/backup/%s' % folderName functions.makePath(backupPath) return backupPath, serverSplit[-1]
def getBackupPath( serverPath ): serverSplit = serverPath.replace( '\\', '/' ).split( '/' ) nowTime = datetime.datetime.now() folderName ='%04d%02d%02d' %( nowTime.year, nowTime.month, nowTime.day ) backupPath = '/'.join( serverSplit[:-1] )+'/backup/%s' % folderName functions.makePath( backupPath ) return backupPath, serverSplit[-1]
def copyFromServerAndOpen( path, *args ): splitPath = path.replace( '\\', '/' ).split( '/' ) fileName = splitPath[-1] nowTime = datetime.datetime.now() folderName ='%04d%02d%02d' %( nowTime.year, nowTime.month, nowTime.day ) currentFolderPath = model.defaultFileBrowserPath +"/"+ folderName functions.makePath( currentFolderPath ) currentFilePath = checkSamePathAndRenamePath( currentFolderPath+'/'+fileName ) print "currentFilePath : ", currentFilePath shutil.copy2( path, currentFilePath ) cmds.file( currentFilePath, f=1, options="v=0;" , ignoreVersion=1, o=1 )
def copyFromServerAndOpen(path, *args): splitPath = path.replace('\\', '/').split('/') fileName = splitPath[-1] nowTime = datetime.datetime.now() folderName = '%04d%02d%02d' % (nowTime.year, nowTime.month, nowTime.day) currentFolderPath = model.defaultFileBrowserPath + "/" + folderName functions.makePath(currentFolderPath) currentFilePath = checkSamePathAndRenamePath(currentFolderPath + '/' + fileName) print "currentFilePath : ", currentFilePath shutil.copy2(path, currentFilePath) cmds.file(currentFilePath, f=1, options="v=0;", ignoreVersion=1, o=1)
def findScenePath(cutPath): sceneFolder = functions.makePath()
def findScenePath( cutPath ): sceneFolder = functions.makePath( )