Changeset 890
- Timestamp:
- Dec 7, 2008, 12:57:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/net.sf.basedb.pluginutilities/trunk/src/net/sf/basedb/plugins/AbstractRunBinaryPlugin.java
r862 r890 48 48 49 49 import java.io.IOException; 50 import java.io.PrintStream; 50 51 51 52 import java.util.ArrayList; … … 68 69 69 70 @author Jari Hakkinen 70 @version MAKESUBSTOFVERSIONNUMBER71 71 @since BASE 2.9 72 72 @base.modified $Date$ … … 78 78 { 79 79 80 protected AbstractRunBinaryPlugin() {} 80 protected AbstractRunBinaryPlugin() { 81 if (debug_output) 82 try 83 { 84 System.setErr(new PrintStream(debug_outputfile)); 85 System.err.println("Initializing super class"); 86 } 87 catch (IOException e) { 88 e.printStackTrace(); 89 } 90 } 81 91 82 92 @SuppressWarnings("unchecked") 83 93 public void configure(GuiContext context, Request request, Response response) 84 94 { 95 if (debug_output) System.err.println("Configuring"); 85 96 try 86 97 { … … 122 133 response.setError(e.getMessage(), Arrays.asList(e)); 123 134 } 135 if (debug_output) System.err.println("Configuring done"); 124 136 } 125 137 … … 128 140 throws InterruptedException, IOException 129 141 { 142 if (debug_output) System.err.println("execute"); 130 143 percentDone+=1; 131 144 progress.display(percentDone,"Running " + about.getName()); … … 134 147 int status=p.exitValue(); 135 148 if (status>0) 149 { 150 if (debug_output) System.err.println("execute failed"); 136 151 throw new IOException("Unexpected exit of " + about.getName() + 137 152 "WeNNI sub-process. Return value: " + status); 153 } 154 if (debug_output) System.err.println("execute end succesfully reached"); 138 155 } 139 156 … … 147 164 protected String getBinaryPath(Class cls, String binaryname) 148 165 { 149 if (BinaryPath == null) { 166 if (debug_output) System.err.println("Acquiring binary path"); 167 if (binaryPath == null) { 150 168 DbControl dc = sc.newDbControl(); 151 169 try { … … 155 173 while ((pos>0) && (jarpath.charAt(pos-1)!=java.io.File.separatorChar)) 156 174 --pos; 157 BinaryPath=jarpath.substring(0, pos) + binaryname;175 binaryPath=jarpath.substring(0, pos) + binaryname; 158 176 } 159 177 finally { … … 162 180 } 163 181 } 164 return BinaryPath; 182 if (debug_output) System.err.println("Got binary path " + binaryPath ); 183 return binaryPath; 165 184 } 166 185 … … 187 206 protected java.io.File getExecDirectory() 188 207 { 208 if (debug_output) System.err.println("Acquiring exec direcotry"); 189 209 if (execDirectory == null) { 190 210 execDirectory = new java.io.File … … 193 213 execDirectory.mkdirs(); 194 214 } 215 if (debug_output) System.err.println("Got exec direcotry " + execDirectory); 195 216 return execDirectory; 196 217 } … … 228 249 public void run(Request request, Response response, ProgressReporter progress) 229 250 { 251 if (debug_output) System.err.println("run"); 230 252 DbControl dc=sc.newDbControl(); 231 253 try { … … 248 270 } 249 271 catch (Throwable e) { 272 if (debug_output) System.err.println("run failed: " + e.getMessage()); 250 273 response.setError(e.getMessage(), Arrays.asList(e)); 251 274 } 252 275 finally { 253 // clean up 254 java.io.File[] files=getExecDirectory().listFiles(); 255 for (java.io.File f : files) 256 f.delete(); 257 getExecDirectory().delete(); 276 if (!debug_output) { 277 // clean up 278 java.io.File[] files=getExecDirectory().listFiles(); 279 for (java.io.File f : files) 280 f.delete(); 281 getExecDirectory().delete(); 282 } 283 else 284 { 285 System.err.println("exec directory NOT removed"); 286 } 258 287 if (dc != null) 259 288 dc.close(); 260 289 } 290 if (debug_output) System.err.println("run end"); 261 291 } 262 292 … … 283 313 protected Plugin.MainType plugin_maintype=null; 284 314 285 private String BinaryPath=null;315 private String binaryPath=null; 286 316 private RequestInformation configureJob = null; 287 317 private java.io.File execDirectory; 288 318 private int percentDone=0; 319 320 // debug options. Note, if debug information is on, the exec 321 // directory is not removed after plug-in execution. 322 protected Boolean debug_output=true; 323 private String debug_outputfile="/tmp/base_debug.txt"; 289 324 }
Note: See TracChangeset
for help on using the changeset viewer.