Changeset 906


Ignore:
Timestamp:
Dec 8, 2008, 10:01:51 PM (13 years ago)
Author:
Jari Häkkinen
Message:

Some external binary will output result to stdout ... optionally writing output to file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.pluginutilities/trunk/src/net/sf/basedb/plugins/AbstractRunBinaryPlugin.java

    r891 r906  
    8484      debug_outputfile=(System.getProperty("java.io.tmpdir") +
    8585                        java.io.File.separator + debug_outputfile);
    86       debug_subprocess_outputfile=(System.getProperty("java.io.tmpdir") +
    87                                    java.io.File.separator +
    88                                    debug_subprocess_outputfile);
    8986      try
    9087      {
     
    124121        DbControl dc = sc.newDbControl();
    125122        try {
    126           BioAssaySet source = getSourceBioAssaySet(dc);
    127           int nofAssays = source.getBioAssays().list(dc).size();
     123          sourceBAS = getSourceBioAssaySet(dc);
     124          int nofAssays = sourceBAS.getBioAssays().list(dc).size();
    128125          if (nofAssays>10 && nofAssays<30)
    129126            execTime = Job.ExecutionTime.MEDIUM;
     
    153150    cmd[0]=getBinaryPath(this.getClass(),cmd[0]);
    154151    Process p = Runtime.getRuntime().exec(cmd, null, getExecDirectory());
    155     if (debug_output)
     152    if (subprocess_stdout!=null)
    156153    {
    157154      BufferedInputStream bis=new BufferedInputStream(p.getInputStream());
    158       FileWriter fw=new FileWriter(debug_subprocess_outputfile);
     155      FileWriter fw=new FileWriter(getExecDirectory() + java.io.File.separator +
     156                                   subprocess_stdout);
    159157      int ch;
    160158      while ((ch=bis.read())>-1) fw.write(ch);
     
    274272      if (name==null)
    275273        name="New bioassay set";
    276       BioAssaySet source = getSourceBioAssaySet(dc);
     274      if (sourceBAS==null)
     275        sourceBAS = getSourceBioAssaySet(dc);
    277276      runBinary();
    278277      storeResult(dc,name);
     
    280279      response.setDone("Plug-in ended successfully");
    281280      if (debug_output) System.err.println("run succesful");
     281      response.setError("All is okay, just make sure that BASE produces error.",
     282                        null);
    282283    }
    283284    catch (Throwable e) {
     
    301302    }
    302303    if (debug_output) System.err.println("run end");
    303     response.setError("All is okay, just make sure that BASE produces error.",
    304                       null);
    305304  }
    306305
     
    323322  protected Set<Permissions> permissions = new HashSet<Permissions>();
    324323  protected Plugin.MainType plugin_maintype=null;
     324  protected BioAssaySet sourceBAS = null;
     325  protected String subprocess_stdout=null;
    325326
    326327  private String binaryPath=null;
     
    331332
    332333  // debug settings. Note, if debug information is on, the exec
    333   // directory is not removed after plug-in execution. The file names
    334   // are modified in the constructor to contain the java temp
    335   // directory, i.e. debug files are written into the java temp
    336   // directory. The file names are (somewhat) arbitrarily chosen and
    337   // may overwrite existing files.
    338   protected Boolean debug_output=false;
     334  // directory is not removed after plug-in execution. The file name
     335  // is modified in the constructor to contain the java temp
     336  // directory, i.e. debug file is written into the java temp
     337  // directory. The file name is (somewhat) arbitrarily chosen and may
     338  // overwrite existing file.
     339  protected Boolean debug_output=true;
    339340  private String debug_outputfile="ARBPdebug.txt";
    340   private String debug_subprocess_outputfile="ARBPdebug_subprocess.txt";
    341341}
Note: See TracChangeset for help on using the changeset viewer.