Skip to content

Commit

Permalink
updates MOVESMaster.bat to archive moveslog.txt files instead of only…
Browse files Browse the repository at this point in the history
… keeping the most recent log (#52)

MOVESMaster now renames old log files with the current timestamp and adds them to `moveslog.zip`. This prevents the accidental deletion of old log files.
  • Loading branch information
danielbizercox committed Aug 3, 2022
1 parent 5d0f380 commit 14efa27
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
26 changes: 22 additions & 4 deletions MOVESMaster.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
@echo off
call setenv.bat

set HR=%time:~0,2%
set HR=%Hr: =0%
set HR=%HR: =%
set logfile=moveslog_archive_%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%.txt
if exist sharedwork\*.* erase /Q /S /F sharedwork\*.*
if exist WorkerFolder\*.* erase /Q /S /F WorkerFolder\*.*
if exist moveslog_old.txt erase moveslog_old.txt
if exist moveslog.txt rename moveslog.txt moveslog_old.txt
call setenv.bat
ant rungui

if exist moveslog.txt REN "moveslog.txt" "%logfile%"

if exist %logfile% (
if not exist moveslog.zip (
jar cMf moveslog.zip "%logfile%" && del "%logfile%"
) else (
jar uMf moveslog.zip "%logfile%" && del "%logfile%"
)
)

ant rungui




14 changes: 11 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@
<classpath refid="classpath" />
</java>
</target>

<target name="makejre" depends="compile">
<delete dir="./jre" />
<if>
Expand All @@ -1263,11 +1263,15 @@
<arg value="--module-path" />
<arg value="gov/" />
<arg value="--add-modules" />
<arg value="java.base,java.desktop,java.logging,java.management,java.naming,java.rmi,java.sql,java.xml" />
<arg value="java.base,java.desktop,java.logging,java.management,java.naming,java.rmi,java.sql,java.xml,jdk.jartool" />
<arg value="--output" />
<arg value="jre" />
</exec>
<touch file="jre/lib/tools.jar" />
<exec executable="cmd" spawn="false">
<arg value="/c" />
<arg value="@FOR /F &quot;usebackq delims==&quot; %i IN (`where.exe jar.exe`) DO @copy &quot;%i&quot; &quot;jre/bin/jar.exe&quot; /y >NUL &amp;&amp; @echo Copied &quot;%i&quot; to jre/bin &amp;&amp; @exit" />
</exec>
</then>
<else>
<if>
Expand All @@ -1284,11 +1288,15 @@
<arg value="--module-path" />
<arg value="gov/" />
<arg value="--add-modules" />
<arg value="java.base,java.desktop,java.logging,java.management,java.naming,java.rmi,java.sql,java.transaction.xa,java.xml" />
<arg value="java.base,java.desktop,java.logging,java.management,java.naming,java.rmi,java.sql,java.transaction.xa,java.xml,jdk.jartool" />
<arg value="--output" />
<arg value="jre" />
</exec>
<touch file="jre/lib/tools.jar" />
<exec executable="cmd" spawn="false">
<arg value="/c" />
<arg value="@FOR /F &quot;usebackq delims==&quot; %i IN (`where.exe jar.exe`) DO @copy &quot;%i&quot; &quot;jre/bin/jar.exe&quot; /y >NUL &amp;&amp; @echo Copied &quot;%i&quot; to jre/bin &amp;&amp; @exit" />
</exec>
</then>
<else>
<echo>makejre only works with Java 9 and later</echo>
Expand Down
10 changes: 8 additions & 2 deletions gov/epa/otaq/moves/master/gui/LoopingTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1330,8 +1330,14 @@ void createOutputFiles(ArrayList<ControlFileEntry> entries) {
scriptWriter.println("rem set up moves environment:");
scriptWriter.println("cd \"" + movesFolder + "\"");
scriptWriter.println("call setenv.bat");
scriptWriter.println("if exist moveslog_old.txt erase moveslog_old.txt");
scriptWriter.println("if exist moveslog.txt rename moveslog.txt moveslog_old.txt");
scriptWriter.println("if exist moveslog.txt REN \"moveslog.txt\" \"%logfile%\"");
scriptWriter.println("if exist %logfile% (");
scriptWriter.println(" if not exist moveslog.zip ( ");
scriptWriter.println(" jar cMf moveslog.zip \"%logfile%\" && del \"%logfile%\"");
scriptWriter.println(" ) else ( ");
scriptWriter.println(" jar uMf moveslog.zip \"%logfile%\" && del \"%logfile%\"");
scriptWriter.println(" )");
scriptWriter.println(")");
scriptWriter.println("rem ----------------------------------------------------------- \n");
scriptWriter.println("rem Run MOVES for each runspec:");

Expand Down

0 comments on commit 14efa27

Please sign in to comment.