Commit e8806ea6 authored by Robert Smith's avatar Robert Smith
Browse files

Merge remote-tracking branch 'origin/2.2.1' into next

parents 26ac4359 c86826e6
...@@ -21,10 +21,8 @@ import java.util.ArrayList; ...@@ -21,10 +21,8 @@ import java.util.ArrayList;
import java.util.Dictionary; import java.util.Dictionary;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ice.datastructures.form.FormStatus; import org.eclipse.ice.datastructures.form.FormStatus;
/** /**
...@@ -72,19 +70,20 @@ import org.eclipse.ice.datastructures.form.FormStatus; ...@@ -72,19 +70,20 @@ import org.eclipse.ice.datastructures.form.FormStatus;
* </p> * </p>
* </td> * </td>
* </tr> * </tr>
* * <tr> * *
* <td> * <tr>
* <p> * <td>
* localJobLaunchDirectory * <p>
* </p> * localJobLaunchDirectory
* </td> * </p>
* <td> * </td>
* <p> * <td>
* The name of the directory within the project/jobs folder where * <p>
* the files to be uploaded can be found (optional). * The name of the directory within the project/jobs folder where the files to
* </p> * be uploaded can be found (optional).
* </td> * </p>
* </tr> * </td>
* </tr>
* <tr> * <tr>
* <td> * <td>
* <p> * <p>
...@@ -187,18 +186,19 @@ import org.eclipse.ice.datastructures.form.FormStatus; ...@@ -187,18 +186,19 @@ import org.eclipse.ice.datastructures.form.FormStatus;
* </p> * </p>
* </td> * </td>
* </tr> * </tr>
* * <tr> * *
* <td> * <tr>
* <p> * <td>
* os * <p>
* </p> * os
* </td> * </p>
* <td> * </td>
* <p> * <td>
* The name of the operating system. * <p>
* </p> * The name of the operating system.
* </td> * </p>
* </tr> * </td>
* </tr>
* </table> * </table>
* *
* @author Alex McCaskey * @author Alex McCaskey
...@@ -238,15 +238,15 @@ public class LocalExecutionAction extends Action { ...@@ -238,15 +238,15 @@ public class LocalExecutionAction extends Action {
private ExecutionHelper helper; private ExecutionHelper helper;
/** /**
* The constructor. * The constructor.
*/ */
public LocalExecutionAction() { public LocalExecutionAction() {
// Initialize the cancelled flag and // Initialize the cancelled flag and
// the form status. // the form status.
status = FormStatus.ReadyToProcess; status = FormStatus.ReadyToProcess;
cancelled = new AtomicBoolean(false); cancelled = new AtomicBoolean(false);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
...@@ -275,8 +275,10 @@ public class LocalExecutionAction extends Action { ...@@ -275,8 +275,10 @@ public class LocalExecutionAction extends Action {
// Write some header information first // Write some header information first
try { try {
stdOut.write(helper.createOutputHeader("standard output", fullCMD)); stdOut.write(
stdErr.write(helper.createOutputHeader("standard error", fullCMD)); helper.createOutputHeader("standard output", fullCMD));
stdErr.write(
helper.createOutputHeader("standard error", fullCMD));
} catch (IOException e) { } catch (IOException e) {
// Complain // Complain
logger.error(getClass().getName() + " Exception!", e); logger.error(getClass().getName() + " Exception!", e);
...@@ -300,7 +302,8 @@ public class LocalExecutionAction extends Action { ...@@ -300,7 +302,8 @@ public class LocalExecutionAction extends Action {
status = FormStatus.Processed; status = FormStatus.Processed;
return status; return status;
} else { } else {
logger.error("Local Execution Error - the input data map was not valid."); logger.error(
"Local Execution Error - the input data map was not valid.");
status = FormStatus.InfoError; status = FormStatus.InfoError;
return status; return status;
} }
...@@ -371,14 +374,18 @@ public class LocalExecutionAction extends Action { ...@@ -371,14 +374,18 @@ public class LocalExecutionAction extends Action {
} }
/** /**
* Launch each of the commands in this local execution. * Launch each of the commands in this local execution.
* *
* @param cmd Command to execute * @param cmd
* @param stdOut Standard out writer * Command to execute
* @param stdErr Standard error writer. * @param stdOut
* Standard out writer
* @param stdErr
* Standard error writer.
* @return * @return
*/ */
protected FormStatus launchStageLocally(String cmd, BufferedWriter stdOut, BufferedWriter stdErr) { protected FormStatus launchStageLocally(String cmd, BufferedWriter stdOut,
BufferedWriter stdErr) {
// Local Declarations // Local Declarations
String errMsg = null; String errMsg = null;
...@@ -395,6 +402,9 @@ public class LocalExecutionAction extends Action { ...@@ -395,6 +402,9 @@ public class LocalExecutionAction extends Action {
if (!os.toLowerCase().contains("win")) { if (!os.toLowerCase().contains("win")) {
cmdList.add("/bin/bash"); cmdList.add("/bin/bash");
cmdList.add("-c"); cmdList.add("-c");
// } else{
// cmdList.add("CMD");
// cmdList.add("/C");
} }
// Add the command to the list. It will either be just the command // Add the command to the list. It will either be just the command
...@@ -415,8 +425,40 @@ public class LocalExecutionAction extends Action { ...@@ -415,8 +425,40 @@ public class LocalExecutionAction extends Action {
} }
} catch (IOException e) { } catch (IOException e) {
// Grab the error // Grab the error
errMsg = e.getMessage(); errMsg = null;
logger.error(getClass().getName() + " Exception! ", e);
// Just Log the erroron Mac and Linux
if (!os.toLowerCase().contains("win")) {
errMsg = e.getMessage();
logger.error(getClass().getName() + " Exception! ", e);
} else {
// If this is a windows machine, try to run in the command
// prompt
cmdList.add(0, "CMD");
cmdList.add(1, "/C");
// Launch the command. The command must be split on spaces to
// run
// through a Java Process because the process tries to execute
// the whole
// thing as a single command with the arguments give after it.
jobBuilder = new ProcessBuilder(cmdList);
jobBuilder.directory(directory);
// Do not direct the error to stdout. Catch it separately.
jobBuilder.redirectErrorStream(false);
try {
// Only launch the stage if it hasn't been cancelled.
if (!cancelled.get()) {
job = jobBuilder.start();
}
} catch (IOException e2) {
errMsg = e2.getMessage();
logger.error(getClass().getName() + " Exception! ", e2);
}
}
} }
// Log any errors and return // Log any errors and return
if (errMsg != null) { if (errMsg != null) {
...@@ -434,13 +476,15 @@ public class LocalExecutionAction extends Action { ...@@ -434,13 +476,15 @@ public class LocalExecutionAction extends Action {
} }
// Print the execution command // Print the execution command
logger.info("LocalExecutionAction Message: " + "Launching local command: " + "\"" + cmd + "\""); logger.info("LocalExecutionAction Message: "
+ "Launching local command: " + "\"" + cmd + "\"");
// Log the output // Log the output
stdOutStream = job.getInputStream(); stdOutStream = job.getInputStream();
stdErrStream = job.getErrorStream(); stdErrStream = job.getErrorStream();
logOutput(stdOutStream, stdErrStream); logOutput(stdOutStream, stdErrStream);
if (logOutput(stdOutStream, stdErrStream).equals(FormStatus.InfoError)) { if (logOutput(stdOutStream, stdErrStream)
.equals(FormStatus.InfoError)) {
// Throw an error if the streaming fails // Throw an error if the streaming fails
return FormStatus.InfoError; return FormStatus.InfoError;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment