use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class InstallPackageCommand method executeScript.
private ScriptResult executeScript(Map<String, Object> schedulerProperties, String packageDirPath) throws InvalidScriptException {
ByteArrayOutputStream outputStream = null;
PrintStream printStream = null;
File scriptFile = new File(PASchedulerProperties.getAbsolutePath(SCRIPT_PATH));
String[] param = { packageDirPath };
ScriptResult scriptResult = null;
if (scriptFile.exists()) {
outputStream = new ByteArrayOutputStream();
printStream = new PrintStream(outputStream, true);
scriptResult = new SimpleScript(scriptFile, param).execute(schedulerProperties, printStream, printStream);
logger.info(outputStream.toString());
outputStream.reset();
} else {
logger.warn("Load package script " + scriptFile.getPath() + " not found");
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
// ignore
}
}
if (printStream != null) {
printStream.close();
}
return scriptResult;
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class TestForkEnvironment method testScript.
@Test
public void testScript() throws InvalidScriptException {
forkEnvironment.setEnvScript(new SimpleScript("var a=1;", "js"));
Assert.assertTrue(forkEnvironment.getEnvScript() != null);
forkEnvironment.setEnvScript(null);
Assert.assertTrue(forkEnvironment.getEnvScript() == null);
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class TaskContextTest method createTaskContext.
private TaskContext createTaskContext() throws NodeException, InvalidScriptException {
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1L, "testSerializeContextToFile"), "testSerializeContextToFile", 1L));
// Invoke method to test it
return new TaskContext(new ScriptExecutableContainer(new TaskScript(new ForkEnvironmentScript(new SimpleScript("", "python")))), taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class TaskContextSerializerTest method createTaskContext.
private TaskContext createTaskContext() throws NodeException, InvalidScriptException {
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1L, "testSerializeContextToFile"), "testSerializeContextToFile", 1L));
// Invoke method to test it
return new TaskContext(new ScriptExecutableContainer(new TaskScript(new ForkEnvironmentScript(new SimpleScript("", "python")))), taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class ForkedJvmTaskExecutionCommandCreatorTest method createTaskContext.
private TaskContext createTaskContext() throws InvalidScriptException, NodeException {
ScriptExecutableContainer scriptContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript")));
TaskLauncherInitializer taskLauncherInitializer = getTaskLauncherInitializerWithWorkflowVariableAndForkEnvironment();
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
return taskContext;
}
Aggregations