1 package com.neuronrobotics.bowlerstudio.scripting;
3 import java.io.BufferedReader;
5 import java.io.InputStreamReader;
6 import java.util.ArrayList;
7 import java.util.Arrays;
10 import com.neuronrobotics.video.OSUtil;
15 public Object
inlineScriptRun(File code, ArrayList<Object> args)
throws Exception {
17 ArrayList<String> commands =
new ArrayList<>();
19 commands.add(code.getAbsolutePath());
21 for (Object o : args) {
22 commands.add(o.toString());
25 ProcessBuilder pb =
new ProcessBuilder(commands);
27 pb.directory(code.getParentFile());
29 Process process = pb.start();
32 BufferedReader stdInput =
new BufferedReader(
new InputStreamReader(process.getInputStream()));
33 BufferedReader errInput =
new BufferedReader(
new InputStreamReader(process.getErrorStream()));
38 ArrayList<String> back =
new ArrayList<>();
39 while ((s = stdInput.readLine()) !=
null || (e = errInput.readLine()) !=
null) {
42 System.out.println(s);
45 System.out.println(e);
51 while (process.isAlive()) {
58 public Object
inlineScriptRun(String code, ArrayList<Object> args)
throws Exception {
59 throw new RuntimeException(
"Bash scripts have to be sent as files");
69 if (OSUtil.isWindows())
70 return new ArrayList<>();
71 return new ArrayList<>(Arrays.asList(
".sh",
".bash"));
80 return "echo Hello World";
String getDefaultContents()
Object inlineScriptRun(String code, ArrayList< Object > args)
Object inlineScriptRun(File code, ArrayList< Object > args)
ArrayList< String > getFileExtenetion()