use of blue.utilities.ProcessRunner in project blue by kunstmusik.
the class ExternalScoreEngine method evalCode.
@Override
public String evalCode(String code, Map<String, Object> initValues) throws ScriptException {
ProcessRunner processRunner = new ProcessRunner();
File currentWorkingDirectory = null;
try {
// output text from soundObject to a temp file for processing by
// external program
File temp = FileUtilities.createTempTextFile("blueTempText", ".txt", BlueSystem.getCurrentProjectDirectory(), code);
StringBuilder buffer = new StringBuilder();
String commandLine = (String) initValues.get("commandline");
currentWorkingDirectory = temp.getParentFile();
// and grab from stdin
if (!commandLine.contains("$outfile")) {
commandLine = getPreparedCommandLine(commandLine, temp.getName());
System.out.println("Calling command: " + commandLine);
System.out.println("Using directory: " + currentWorkingDirectory.getAbsolutePath());
processRunner.execWaitAndCollect(commandLine, currentWorkingDirectory);
buffer.append(processRunner.getCollectedOutput());
} else {
File outFile = File.createTempFile("blueTempOutFile", ".sco", BlueSystem.getCurrentProjectDirectory());
outFile.deleteOnExit();
commandLine = this.getPreparedCommandLine(commandLine, temp.getName(), outFile.getName());
System.out.println("Calling command: " + commandLine);
System.out.println("Using directory: " + currentWorkingDirectory.getAbsolutePath());
processRunner.execWait(commandLine, currentWorkingDirectory);
buffer.append(blue.utility.TextUtilities.getTextFromFile(outFile));
}
return buffer.toString();
} catch (Exception ex) {
throw new ScriptException(ex);
}
}
use of blue.utilities.ProcessRunner in project blue by kunstmusik.
the class DriverUtilities method getAudioDevicesJackLsp.
protected static List<DeviceInfo> getAudioDevicesJackLsp(boolean isInput) {
List<DeviceInfo> devices = new ArrayList<>();
ProcessRunner pc = new ProcessRunner();
String retVal = null;
String portType = "audio";
String subType = isInput ? "output" : "input";
String prepend = isInput ? "adc:" : "dac:";
String path = System.getenv("PATH");
if (!File.pathSeparator.equals(";")) {
path += File.pathSeparator + "/usr/local/bin";
}
String[] paths = path.split(File.pathSeparator);
String jackLspPath = findExecutableInPath("jack_lsp", paths);
if (jackLspPath == null || jackLspPath.length() == 0) {
return null;
}
try {
pc.execWaitAndCollect(jackLspPath + " -t -p", null);
retVal = pc.getCollectedOutput();
} catch (IOException ex) {
ex.printStackTrace();
}
if (retVal == null || retVal.length() == 0) {
return null;
}
parseJackLspOutput(retVal, portType, subType, prepend, devices);
return devices;
}
Aggregations