use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project phoenicis by PhoenicisOrg.
the class EngineToolsManager method runTool.
/**
* runs a tool in a given container
* @param engineId ID of the engine which provides the tool (e.g. "Wine")
* @param container name of the container
* @param toolId ID of the tool
* @param doneCallback callback executed after the script ran
* @param errorCallback callback executed in case of an error
*/
public void runTool(String engineId, String container, String toolId, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Engines\", \"" + engineId + "\", \"Tools\", \"" + toolId + "\"]);", ignored -> interactiveScriptSession.eval("new " + toolId + "()", output -> {
final ScriptObjectMirror toolObject = (ScriptObjectMirror) output;
toolObject.callMember("run", container);
doneCallback.run();
}, errorCallback), errorCallback);
}
use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.
the class WinePrefixContainerController method killProcesses.
public void killProcesses(WinePrefixContainerDTO winePrefix, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("prefix", winePrefix.getName());
wine.callMember("kill");
doneCallback.run();
}, errorCallback), errorCallback);
}
use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.
the class EnginesSource method fetchAvailableEngines.
public void fetchAvailableEngines(Consumer<List<EngineCategoryDTO>> callback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
List<EngineCategoryDTO> engines = new ArrayList<>();
interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine().getAvailableVersions()", output -> {
EngineCategoryDTO wine = new EngineCategoryDTO.Builder().withName("Wine").withDescription("Wine").withSubCategories(unSerialize(output)).build();
engines.add(wine);
callback.accept(engines);
}, this::throwError), this::throwError);
}
use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.
the class WinePrefixContainerController method runInPrefix.
public void runInPrefix(WinePrefixContainerDTO winePrefix, String command, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("prefix", winePrefix.getName());
wine.callMember("run", command);
wine.callMember("wait");
doneCallback.run();
}, errorCallback), errorCallback);
}
use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.
the class EnginesController method deleteEngine.
private void deleteEngine(EngineDTO engineDTO, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"" + engineDTO.getCategory() + "\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("delete", engineDTO.getCategory(), engineDTO.getSubCategory(), engineDTO.getVersion(), engineDTO.getUserData());
}, errorCallback), errorCallback);
}
Aggregations