Skip to content

Commit

Permalink
redirect POST.* output to out.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
yannrichet committed Dec 28, 2023
1 parent fff050a commit 47e2a0f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/java/org/funz/calculator/plugin/DefaultCodeLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected int runCommand() throws Exception {
if (prebat.isFile()) {
System.err.println("Launching PRE.bat");
try {
new org.funz.util.Process("cmd.exe " + prebat.getName(), _dir, null).runCommand();
new org.funz.util.Process("cmd.exe " + prebat.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch PRE.bat:\n" + e);
}
Expand All @@ -98,7 +98,7 @@ protected int runCommand() throws Exception {
if (presh.isFile()) {
System.err.println("Launching PRE.sh");
try {
new org.funz.util.Process("/bin/sh " + presh.getName(), _dir, null).runCommand();
new org.funz.util.Process("/bin/sh " + presh.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch PRE.sh:\n" + e);
}
Expand All @@ -109,19 +109,19 @@ protected int runCommand() throws Exception {
System.err.println("Launching PRE.py");
if (ParserUtils.getASCIIFileContent(prepy).contains("print(")) {
try {
new org.funz.util.Process("python3 " + prepy.getName(), _dir, null).runCommand();
new org.funz.util.Process("python3 " + prepy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch PRE.py:\n" + e);
}
} else if (ParserUtils.getASCIIFileContent(prepy).contains("print ")) {
try {
new org.funz.util.Process("python2 " + prepy.getName(), _dir, null).runCommand();
new org.funz.util.Process("python2 " + prepy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch PRE.py:\n" + e);
}
} else {
try {
new org.funz.util.Process("python " + prepy.getName(), _dir, null).runCommand();
new org.funz.util.Process("python " + prepy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch PRE.py:\n" + e);
}
Expand All @@ -147,7 +147,7 @@ public void over(int i) {
if (postbat.isFile()) {
System.err.println("Launching POST.bat");
try {
new org.funz.util.Process("cmd.exe " + postbat.getName(), _dir, null).runCommand();
new org.funz.util.Process("cmd.exe " + postbat.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch POST.bat:\n" + e);
}
Expand All @@ -157,7 +157,7 @@ public void over(int i) {
if (postsh.isFile()) {
System.err.println("Launching POST.sh");
try {
new org.funz.util.Process("/bin/sh " + postsh.getName(), _dir, null).runCommand();
new org.funz.util.Process("/bin/sh " + postsh.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch POST.sh:\n" + e);
}
Expand All @@ -168,20 +168,20 @@ public void over(int i) {
System.err.println("Launching POST.py");
if (ParserUtils.getASCIIFileContent(postpy).contains("print(")) {
try {
new org.funz.util.Process("python3 " + postpy.getName(), _dir, null).runCommand();
new org.funz.util.Process("python3 " + postpy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
//new org.funz.util.Process("python3 " + postpy.getName());
} catch (Exception e) {
System.err.println("could not launch POST.py:\n" + e);
}
} else if (ParserUtils.getASCIIFileContent(postpy).contains("print ")) {
try {
new org.funz.util.Process("python2 " + postpy.getName(), _dir, null).runCommand();
new org.funz.util.Process("python2 " + postpy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch POST.py:\n" + e);
}
} else {
try {
new org.funz.util.Process("python " + postpy.getName(), _dir, null).runCommand();
new org.funz.util.Process("python " + postpy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch POST.py:\n" + e);
}
Expand Down Expand Up @@ -280,7 +280,7 @@ public void stopRunning() {
if (killbat.isFile()) {
System.err.println("Launching STOP.bat");
try {
new org.funz.util.Process("cmd.exe " + killbat.getName(), _dir, null).runCommand();
new org.funz.util.Process("cmd.exe " + killbat.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch STOP.bat:\n" + e);
}
Expand All @@ -291,7 +291,7 @@ public void stopRunning() {
if (killsh.isFile()) {
System.err.println("Launching STOP.sh");
try {
new org.funz.util.Process("/bin/sh " + killsh.getName(), _dir, null).runCommand();
new org.funz.util.Process("/bin/sh " + killsh.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
} catch (Exception e) {
System.err.println("could not launch STOP.sh:\n" + e);
}
Expand Down

0 comments on commit 47e2a0f

Please sign in to comment.