From 993b450ee9d709dc84dfc66f92ae52ffdc223ddd Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 24 Jul 2013 20:51:38 +0200 Subject: [PATCH] Use tags for pacs prim export --- .../generate_simple_max_exporters.py | 2 - .../generate_tagged_max_exporters.py | 2 + .../processes/pacs_prim/1_export.py | 54 +++++- .../pacs_prim/maxscript/pacs_prim_export.ms | 154 ++++++++++++------ .../ecosystems/desert/directories.py | 1 + .../ecosystems/jungle/directories.py | 1 + .../ecosystems/lacustre/directories.py | 1 + .../ecosystems/primes_racines/directories.py | 1 + 8 files changed, 158 insertions(+), 58 deletions(-) diff --git a/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py b/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py index f034c5d19..cd8a9039f 100644 --- a/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py +++ b/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py @@ -88,8 +88,6 @@ def generateSimpleMaxExporter(processName, fileExtension, sourceDirectoriesVaria -generateSimpleMaxExporter("pacs_prim", "pacs_prim", "PacsPrimSourceDirectories", "PacsPrimExportDirectory", "PacsPrimInstallDirectory") - generateSimpleMaxExporter("skel", "skel", "SkelSourceDirectories", "SkelExportDirectory", "SkelInstallDirectory") generateSimpleMaxExporter("swt", "swt", "SwtSourceDirectories", "SwtExportDirectory", "SwtInstallDirectory") diff --git a/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py b/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py index e10a23cea..89a65d3fb 100644 --- a/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py +++ b/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py @@ -100,6 +100,8 @@ def generateTaggedMaxExporter(processName, fileExtension, sourceDirectoriesVaria +generateTaggedMaxExporter("pacs_prim", "pacs_prim", "PacsPrimSourceDirectories", "PacsPrimExportDirectory", "PacsPrimTagExportDirectory", "PacsPrimInstallDirectory") + generateTaggedMaxExporter("clodbank", "clod", "ClodSourceDirectories", "ClodExportDirectory", "ClodTagExportDirectory", "ClodInstallDirectory") generateTaggedMaxScript("ig", "ig") diff --git a/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py b/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py index b793fe0f8..f551228c0 100644 --- a/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py +++ b/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py @@ -6,7 +6,7 @@ # # \file 1_export.py # \brief Export pacs_prim -# \date 2011-09-28-07-42-GMT +# \date 2013-07-24-14-21-GMT # \author Jan Boon (Kaetemi) # Python port of game data build pipeline. # Export pacs_prim @@ -33,7 +33,9 @@ sys.path.append("../../configuration") if os.path.isfile("log.log"): os.remove("log.log") -log = open("log.log", "w") +if os.path.isfile("temp_log.log"): + os.remove("temp_log.log") +log = open("temp_log.log", "w") from scripts import * from buildsite import * from process import * @@ -47,6 +49,7 @@ printLog(log, "-------") printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, "") + # Find tools # ... @@ -58,15 +61,18 @@ if MaxAvailable: printLog(log, ">>> Export pacs_prim 3dsmax <<<") mkPath(log, ExportBuildDirectory + "/" + PacsPrimExportDirectory) + mkPath(log, ExportBuildDirectory + "/" + PacsPrimTagExportDirectory) for dir in PacsPrimSourceDirectories: mkPath(log, DatabaseDirectory + "/" + dir) - if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + PacsPrimExportDirectory, ".pacs_prim")): + if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + PacsPrimTagExportDirectory, ".max.tag")): scriptSrc = "maxscript/pacs_prim_export.ms" scriptDst = MaxUserDirectory + "/scripts/pacs_prim_export.ms" outputLogfile = ScriptDirectory + "/processes/pacs_prim/log.log" outputDirectory = ExportBuildDirectory + "/" + PacsPrimExportDirectory + tagDirectory = ExportBuildDirectory + "/" + PacsPrimTagExportDirectory maxSourceDir = DatabaseDirectory + "/" + dir - tagList = findFiles(log, outputDirectory, "", ".pacs_prim") + maxRunningTagFile = tagDirectory + "/max_running.tag" + tagList = findFiles(log, tagDirectory, "", ".max.tag") tagLen = len(tagList) if os.path.isfile(scriptDst): os.remove(scriptDst) @@ -77,18 +83,50 @@ if MaxAvailable: newline = line.replace("%OutputLogfile%", outputLogfile) newline = newline.replace("%MaxSourceDirectory%", maxSourceDir) newline = newline.replace("%OutputDirectory%", outputDirectory) + newline = newline.replace("%TagDirectory%", tagDirectory) sDst.write(newline) sSrc.close() sDst.close() + zeroRetryLimit = 3 while tagDiff > 0: + mrt = open(maxRunningTagFile, "w") + mrt.write("moe-moe-kyun") + mrt.close() printLog(log, "MAXSCRIPT " + scriptDst) subprocess.call([ Max, "-U", "MAXScript", "pacs_prim_export.ms", "-q", "-mi", "-vn" ]) - tagList = findFiles(log, outputDirectory, "", ".pacs_prim") + if os.path.exists(outputLogfile): + try: + lSrc = open(outputLogfile, "r") + for line in lSrc: + lineStrip = line.strip() + if (len(lineStrip) > 0): + printLog(log, lineStrip) + lSrc.close() + os.remove(outputLogfile) + except Exception: + printLog(log, "ERROR Failed to read 3dsmax log") + else: + printLog(log, "WARNING No 3dsmax log") + tagList = findFiles(log, tagDirectory, "", ".max.tag") newTagLen = len(tagList) tagDiff = newTagLen - tagLen tagLen = newTagLen - printLog(log, "Exported " + str(tagDiff) + " .pacs_prim files!") + addTagDiff = 0 + if os.path.exists(maxRunningTagFile): + printLog(log, "FAIL 3ds Max crashed and/or file export failed!") + if tagDiff == 0: + if zeroRetryLimit > 0: + zeroRetryLimit = zeroRetryLimit - 1 + addTagDiff = 1 + else: + printLog(log, "FAIL Retry limit reached!") + else: + addTagDiff = 1 + os.remove(maxRunningTagFile) + printLog(log, "Exported " + str(tagDiff) + " .max files!") + tagDiff += addTagDiff os.remove(scriptDst) + printLog(log, "") @@ -99,8 +137,10 @@ if os.path.isfile(listPath): -printLog(log, "") log.close() +if os.path.isfile("log.log"): + os.remove("log.log") +shutil.move("temp_log.log", "log.log") # end of file diff --git a/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms b/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms index 21bdcdd4c..ddfc0014a 100644 --- a/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms +++ b/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms @@ -8,6 +8,9 @@ -- Allocate 20 Me for the script heapSize += 15000000 +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + nlErrorFilename = "%OutputLogfile%" nlErrorStream = openFile nlErrorFilename mode:"a" if nlErrorStream == undefined then @@ -110,75 +113,128 @@ fn runNelMaxExport inputMaxFile = +removeRunningTag = true + try ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then + undo off ( - -- For each files - for i = 1 to files.count do + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then ( - inputMaxFile = files[i] - outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".pacs_prim") - - try + -- For each files + for i = 1 to files.count do ( - -- Compare file date - if (NeLTestFileDate outputNelFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then ( - runNelMaxExport(inputMaxFile) + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'pacs_prim': can't open the file " + inputMaxFile) + removeRunningTag = false + ) ) else ( - -- Error - nlerror("ERROR exporting 'pacs_prim': can't open the file " + inputMaxFile) + nlerror("SKIPPED BY TAG " + inputMaxFile) ) - ) - else - ( - nlerror("SKIPPED " + inputMaxFile) - ) - ) - catch - ( - -- Error - nlerror("ERROR error exporting 'pacs_prim' in files " + inputMaxFile) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'pacs_prim' in file " + inputMaxFile) + -- removeRunningTag = false + --) ) ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) ) ) catch ( -- Error - nlerror("ERROR fatal error exporting 'pacs_prim' in folder %MaxSourceDirectory%") + nlerror("ERROR Fatal error exporting 'pacs_prim' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occured") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occured") + NelForceQuitRightNow() ) -- Bye - -resetMAXFile #noprompt +nlerror("BYE") quitMAX #noPrompt quitMAX() #noPrompt diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py index e15b856f2..0a0534f1c 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py @@ -206,6 +206,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py index 1ceface1c..716afc247 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py @@ -210,6 +210,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py index af2e15e29..37e35b51e 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py @@ -218,6 +218,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py index d49e8d06b..c718e90ec 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py @@ -203,6 +203,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE ***