Commit f4c93526 authored by Marian Dovgialo's avatar Marian Dovgialo

Added bundled MP5 executor, at first svarog launch if svarog can find bundled...

Added bundled MP5 executor, at first svarog launch if svarog can find bundled MP executable it will be set as default
parent cd126bdc
......@@ -21,6 +21,9 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.Annotations;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import java.io.File;
import java.nio.file.Files;
import org.signalml.method.mp5.MP5BundledProcessExecutor;
/** MP5ExecutorManager
*
......@@ -37,9 +40,23 @@
private transient EventListenerList listenerList = new EventListenerList();
public MP5ExecutorManager() {
defaultExecutor = MP5LocalProcessExecutor.pathExecutor();
MP5Executor path_executor = MP5LocalProcessExecutor.pathExecutor();
MP5BundledProcessExecutor bundled_executor = new MP5BundledProcessExecutor();
String execPath = bundled_executor.getMp5ExecutablePath();
File execFile = new File(execPath);
if (execFile.exists())
{
defaultExecutor = bundled_executor;
}
else
{
defaultExecutor = path_executor;
}
executors = new ArrayList<MP5Executor>();
executors.add(defaultExecutor);
executors.add(path_executor);
executors.add(bundled_executor);
}
@Override
......@@ -55,7 +72,8 @@ private XStream createExecutorStreamer() {
Annotations.configureAliases(
streamer,
MP5ExecutorManager.class,
MP5LocalProcessExecutor.class
MP5LocalProcessExecutor.class,
MP5BundledProcessExecutor.class
//MP5RemoteExecutor.class,
//MP5RemotePasswordExecutor.class
);
......
package org.signalml.method.mp5;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import java.io.File;
import java.util.Locale;
import static org.signalml.app.util.i18n.SvarogI18n._;
@XStreamAlias("mp5bundledexecutor")
public class MP5BundledProcessExecutor extends MP5LocalProcessExecutor{
public MP5BundledProcessExecutor()
{
super();
setName(_("execute from bundled executor"));
}
@Override
public void setMp5ExecutablePath(String mp5ExecutablePath) {
}
@Override
public String getMp5ExecutablePath() {
File jar = new File(MP5LocalProcessExecutor.class.getProtectionDomain().getCodeSource().getLocation().getPath());
String jarDir = jar.getParentFile().getPath();
String executor_folder;
String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
String bits = System.getProperty("sun.arch.data.model");
if ((OS.contains("mac")) || (OS.contains("darwin"))) {
executor_folder = "/mp/osx64/empi-osx64";
} else if (OS.contains("win")) {
executor_folder = "/mp/win" + bits + "/empi-win"+ bits+ ".exe";
} else if (OS.indexOf("nux") >= 0) {
executor_folder = "/mp/linux/empi-lin" + bits;
} else {
executor_folder = "";
}
return jarDir + executor_folder;
}
}
......@@ -21,6 +21,8 @@
import org.signalml.method.MethodExecutionTracker;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import java.net.URLDecoder;
import java.util.Locale;
/** MP5LocalProcessExecutor
*
......@@ -37,7 +39,7 @@
private String uid;
private String name;
private String mp5ExecutablePath;
protected String mp5ExecutablePath;
private transient MP5ConfigCreator configCreator = new MP5ConfigCreator();
private transient RawSignalWriter rawSignalWriter = new RawSignalWriter();
......@@ -138,7 +140,7 @@ public boolean execute(MP5Data data, int segment, File resultFile, MethodExecuti
tracker.setMessage(_("Starting executable"));
boolean executionOk = processController.executeProcess(workingDirectory, mp5ExecutablePath, configFile, tracker);
boolean executionOk = processController.executeProcess(workingDirectory, getMp5ExecutablePath(), configFile, tracker);
if (!executionOk) {
return false;
}
......
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