|
From: <bh...@us...> - 2006-09-22 17:11:29
|
Revision: 206
http://svn.sourceforge.net/cishell/?rev=206&view=rev
Author: bh2
Date: 2006-09-22 10:11:22 -0700 (Fri, 22 Sep 2006)
Log Message:
-----------
Fixed two bugs with static executable runner:
* tokenized the command string so that we can eliminate spurious quotation marks
* output files are correctly linked to now
Modified Paths:
--------------
trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java
Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java
===================================================================
--- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2006-09-21 13:58:29 UTC (rev 205)
+++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2006-09-22 17:11:22 UTC (rev 206)
@@ -70,7 +70,7 @@
String algDir = tempDir + File.separator + props.getProperty("Algorithm-Directory") + File.separator;
chmod(algDir);
- File[] output = execute(algDir + getTemplate(), algDir);
+ File[] output = execute(getTemplate(algDir), algDir);
return toData(output);
} catch (Exception e) {
@@ -137,11 +137,11 @@
}
}
- protected File[] execute(String execString, String baseDir) throws Exception {
+ protected File[] execute(String[] cmdarray, String baseDir) throws Exception {
File dir = new File(baseDir);
String[] beforeFiles = dir.list();
- Process process = Runtime.getRuntime().exec(execString, null, new File(baseDir));
+ Process process = Runtime.getRuntime().exec(cmdarray, null, new File(baseDir));
logStream(LogService.LOG_INFO, process.getInputStream());
logStream(LogService.LOG_ERROR, process.getErrorStream());
@@ -154,7 +154,6 @@
Arrays.sort(afterFiles);
List outputs = new ArrayList();
- String tempDir = this.tempDir + File.separator;
int beforeIndex = 0;
int afterIndex = 0;
@@ -164,14 +163,14 @@
beforeIndex++;
afterIndex++;
} else {
- outputs.add(new File(tempDir + afterFiles[afterIndex]));
+ outputs.add(new File(baseDir + afterFiles[afterIndex]));
afterIndex++;
}
- }
+ }
//get any remaining new files
while (afterIndex < afterFiles.length) {
- outputs.add(new File(tempDir + afterFiles[afterIndex]));
+ outputs.add(new File(baseDir + afterFiles[afterIndex]));
afterIndex++;
}
@@ -196,14 +195,24 @@
}
}
- protected String getTemplate() {
- String template = props.getProperty("template");
+ protected String[] getTemplate(String algDir) {
+ String template = "" + props.getProperty("template");
+ String[] cmdarray = template.split("\\s");
- template = template.replaceAll("\\$\\{executable\\}", props.getProperty("executable"));
+ for (int i=0; i < cmdarray.length; i++) {
+ cmdarray[i] = substiteVars(cmdarray[i]);
+ }
+ cmdarray[0] = algDir + cmdarray[0];
+ return cmdarray;
+ }
+
+ protected String substiteVars(String str) {
+ str = str.replaceAll("\\$\\{executable\\}", props.getProperty("executable"));
+
for (int i=0; i < data.length; i++) {
String file = ((File) data[i].getData()).getAbsolutePath();
- template = template.replaceAll("\\$\\{inFile\\["+i+"\\]\\}", "\""+file+"\"");
+ str = str.replaceAll("\\$\\{inFile\\["+i+"\\]\\}", file);
}
for (Enumeration i=parameters.keys(); i.hasMoreElements(); ) {
@@ -212,10 +221,10 @@
if (value == null) value = "";
- template = template.replaceAll("\\$\\{"+key+"\\}", value.toString());
+ str = str.replaceAll("\\$\\{"+key+"\\}", value.toString());
}
- return template;
+ return str;
}
public File getTempDirectory() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|