Displaying differences for changeset
 
display as  

nbproject/build-impl.xml

@@ -1135,6 +1135,7 @@
         <copyfiles files="${file.reference.vecmath-1.3.2.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.xsd-2.6.0.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.commons-lang-2.4.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.sqljdbc4.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <mkdir dir="${build.web.dir}/META-INF"/>
         <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
     </target>
@@ -1242,6 +1243,7 @@
         <copyfiles files="${file.reference.vecmath-1.3.2.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.xsd-2.6.0.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.commons-lang-2.4.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.sqljdbc4.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
     </target>
     <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
         <delete dir="${build.web.dir}/WEB-INF/lib"/>

nbproject/project.properties

@@ -130,6 +130,7 @@
 file.reference.Man2Weps.jar=lib/Man2Weps.jar
 file.reference.oro-2.0.8.jar=lib/oro-2.0.8.jar
 file.reference.postgresql-9.0-801.jdbc4.jar=lib/postgresql-9.0-801.jdbc4.jar
+file.reference.sqljdbc4.jar=lib/sqljdbc4.jar
 file.reference.truezip_6.6.jar=lib/truezip_6.6.jar
 file.reference.vecmath-1.3.2.jar=lib/geotools/vecmath-1.3.2.jar
 file.reference.WepsReportData.jar=lib/WepsReportData.jar
@@ -245,7 +246,8 @@
     ${file.reference.jts-1.13.jar}:\
     ${file.reference.vecmath-1.3.2.jar}:\
     ${file.reference.xsd-2.6.0.jar}:\
-    ${file.reference.commons-lang-2.4.jar}
+    ${file.reference.commons-lang-2.4.jar}:\
+    ${file.reference.sqljdbc4.jar}
 # Space-separated list of extra javac options
 javac.compilerargs=
 javac.debug=true

nbproject/project.xml

@@ -424,6 +424,10 @@
                     <file>${file.reference.commons-lang-2.4.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
+                <library dirs="200">
+                    <file>${file.reference.sqljdbc4.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
             </web-module-libraries>
             <web-module-additional-libraries/>
             <source-roots>

src/java/m/rusle2/R2Run.java

@@ -5,6 +5,8 @@
 package m.rusle2;
 
 import csip.Config;
+import csip.Executable;
+import csip.ServiceException;
 import java.io.File;
 import java.io.IOException;
 import java.util.logging.Logger;
@@ -83,11 +85,51 @@
      * @return
      * @throws IOException
      */
-    int executePyrome(File r2_rsh) throws IOException {
+    int executePyrome(File r2_rsh, Executable python) throws IOException, ServiceException {
+        LOG.info("Execute method");
+        //String binDir = Config.getString("m.bin.dir", "/tmp/csip/bin");
+
+        //File romeshell = Binaries.unpackResource("/bin/win-x86/RomeShell.exe", new File(binDir));
+
+        //Executable python = getResourceExe(V2_0_1.PYTHON);
+        python.setArguments("rusle2csip.py");
+        LOG.info("Executing pyrome rusle2");
+        int ret = python.exec();
+        LOG.info("executed pyrome rusle2");
+        if (ret != 0) {
+            throw new ServiceException("RUSLE 2 PYTHON error: error executing pyrome:" + ret);
+        }
+        
+//        Binaries.unpackResource("/bin/win-x86/RomeDLL.dll", new File(binDir));
+//        Binaries.unpackResource("/bin/win-x86/pyrome.py", new File(binDir));
+//        Binaries.unpackResource("/bin/win-x86/_pyrome.pyd", new File(binDir));  
+//        File runpyrome = new File(r2_rsh.getParent() + "/runrusle2.sh");
+//        String runrusle2 = "winetricks vd=off ; wine /home/ubuntu/.wine/drive_c/Python34/python.exe rusle2csip.py\n"; 
+//        FileUtils.writeStringToFile(runpyrome, runrusle2);
+//        runpyrome.setExecutable(true);
+//        pc.exe = "./runrusle2.sh";
+//        pc.working_dir = r2_rsh.getParent();
+//        pc.args = new String[]{};
+        stdout += "\n" + FileUtils.readFileToString(python.stdout());
+        stderr += "\n" + FileUtils.readFileToString(python.stderr());
+//        LOG.info("Executing pyrome rusle2");
+//        pc.execute();
+//        LOG.info("executed pyrome rusle2");
+//        stdout += "\n" + pc.stdout;
+//        stderr += "\n" + pc.stderr;
+        LOG.info("stdout: "+ stdout);
+        LOG.info(("stderr: "+ stderr));
+        //LOG.info("rusle2 model run stdout=" + stdout);
+        LOG.info("exit val: "+ret);
+        return ret;
+    }
+    
+    int executePyromeLegacy(File r2_rsh) throws IOException, ServiceException {
         LOG.info("Execute method");
         String binDir = Config.getString("m.bin.dir", "/tmp/csip/bin");
 
-        //File romeshell = Binaries.unpackResource("/bin/win-x86/RomeShell.exe", new File(binDir));
+        File romeshell = Binaries.unpackResource("/bin/win-x86/RomeShell.exe", new File(binDir));
+
         Binaries.unpackResource("/bin/win-x86/RomeDLL.dll", new File(binDir));
         Binaries.unpackResource("/bin/win-x86/pyrome.py", new File(binDir));
         Binaries.unpackResource("/bin/win-x86/_pyrome.pyd", new File(binDir));  
@@ -105,7 +147,6 @@
         stderr += "\n" + pc.stderr;
         LOG.info("stdout: "+ stdout);
         LOG.info(("stderr: "+ stderr));
-        //LOG.info("rusle2 model run stdout=" + stdout);
         LOG.info("exit val: "+pc.exitValue);
         return pc.exitValue;
     }

src/java/m/rusle2/V2_0.java

@@ -146,7 +146,7 @@
 
     @Override
     protected String process() throws Exception {
-        int result = r2run.executePyrome(new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT));
+        int result = r2run.executePyromeLegacy(new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT));
         if (result != 0) {
             return EXEC_FAILED;
         }

src/java/m/rusle2/V2_0_1.java

@@ -7,12 +7,11 @@
 import c.GIS_DB;
 import c.GIS_DB_Factory;
 import csip.Config;
+import csip.Executable;
 import csip.ServiceException;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.util.*;
-import javax.ws.rs.*;
-import oms3.annotations.*;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.codehaus.jettison.json.JSONArray;
@@ -29,13 +28,27 @@
 import static csip.ModelDataService.REPORT_TYPE;
 import static csip.ModelDataService.REPORT_VALUE;
 import static csip.ModelDataService.VALUE;
+import csip.annotations.Polling;
+import csip.annotations.Resource;
+import csip.annotations.ResourceType;
+import static csip.annotations.ResourceType.ARCHIVE;
+import static csip.annotations.ResourceType.FILE;
+import static csip.annotations.ResourceType.REFERENCE;
 import static util.ErosionConst.*;
 
 import csip.utils.Binaries;
 import csip.utils.JSONUtils;
 import csip.utils.Services;
-import csip.annotations.Polling;
 import java.util.logging.Level;
+import javax.ws.rs.Path;
+import static m.rusle2.V2_0_1.PYROME;
+import static m.rusle2.V2_0_1.PYROMESRC;
+import static m.rusle2.V2_0_1.PYTHON;
+import static m.rusle2.V2_0_1.PYTHONZIP;
+import static m.rusle2.V2_0_1.ROMEDLL;
+import oms3.annotations.Description;
+import oms3.annotations.Name;
+import oms3.annotations.VersionInfo;
 
 /**
  * REST Web Service. Front end callable.
@@ -47,11 +60,26 @@
 @VersionInfo("2.0.1")
 @Path("m/rusle2/2.0.1")
 @Polling(first = 1000, next = 1000)
+
+//        Binaries.unpackResource("/bin/win-x86/pyrome.py", new File(binDir));
+//        Binaries.unpackResource("/bin/win-x86/_pyrome.pyd", new File(binDir));  
+
+@Resource(type = FILE, file = "/bin/win-x86/RomeDLL.dll", id = ROMEDLL)
+@Resource(type = FILE, file = "/bin/win-x86/pyrome.py", id = PYROMESRC)
+@Resource(type = FILE, file = "/bin/win-x86/_pyrome.pyd", id = PYROME)
+@Resource(type = ARCHIVE, file = "/bin/win-x86/Python34.zip", id = PYTHONZIP)
+@Resource(type = REFERENCE, file = "${csip.dir}/bin/win-x86/Python34/python.exe", wine = true, id = PYTHON)
+
 public class V2_0_1 extends ModelDataService {
 
     static final boolean PRODUCTION_MODE = true;
     //
     static final String R2_TMP_FILENAME = "rusle2csip";
+    static final String ROMEDLL = "RomeDLL.dll";
+    static final String PYROMESRC = "pyrome.py";
+    static final String PYROME = "_pyrome.pyd";
+    static final String PYTHONZIP = "Python34.zip";
+    static final String PYTHON = "python.exe";
     static final String R2_TMP_FILEEXT = ".py";
     static final String IO_TIMING_FILENAME = "/tmp/io-timing";
     static final String IO_TIMING_FILEEXT = ".txt";
@@ -146,7 +174,8 @@
     @Override
     protected void doProcess() throws Exception {
         try  {
-            int result = r2run.executePyrome(new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT));
+            Executable python = getResourceExe(V2_0_1.PYTHON);
+            int result = r2run.executePyrome(new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT), python);
         }
         catch (Exception e) {
             LOG.log(Level.SEVERE, "ERROR EXECUTING PYTHON-RUSLE2", e);
@@ -156,7 +185,10 @@
 
     @Override
     protected String process() throws Exception {
-        int result = r2run.executePyrome(new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT));
+        Executable python = getResourceExe(V2_0_1.PYTHON);
+        
+        
+        int result = r2run.executePyrome(new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT), python);
         if (result != 0) {
             return EXEC_FAILED;
         }
@@ -511,7 +543,9 @@
         FileOutputStream fos = new FileOutputStream(file);
 
         fos.write("import sys\n".getBytes());
-        fos.write("sys.path.append('/tmp/csip/bin/bin/win-x86/')\n".getBytes());
+        // could rewrite this line based on the OS, but python is interpretting it ok on windows
+        fos.write("sys.path.append('/tmp/csip/bin/win-x86/')\n".getBytes());
+        //fos.write("sys.path.append('c:\\\\tmp\\\\csip\\\\bin\\\\win-x86\\\\')\n".getBytes());
 
         fos.write("from pyrome import *\n".getBytes());
         fos.write("from time import sleep\n".getBytes());

src/java/m/weps/V1_3_1.java

@@ -46,8 +46,7 @@
 @Polling(first = 25000, next = 2000)
 
 // weps, weps.version is in the csip-conf.file
-//@Resource(type = EXECUTABLE, file = "/bin/${arch}/${weps.version}/weps.exe", id = WEPS_EXE)
-@Resource(type = EXECUTABLE, file = "/bin/${arch}/1.3.9/weps.exe", id = WEPS_EXE)
+@Resource(type = EXECUTABLE, file = "/bin/${arch}/${weps.version}/weps.exe", id = WEPS_EXE)
 //@Resource(type = EXECUTABLE, file = "/bin/${csip.arch}/weps", id = WEPS_EXE)
 ////@Resource(type = EXECUTABLE, file = "/bin/lin-amd64/weps-1.3.9", id = WEPS_EXE)
 // cligen
@@ -81,6 +80,7 @@
     static final String BOUNDARY_POL = "boundary.pol";
     static final String DEFAULT_WIND_STATION_DB = "wind_gen_his_upper_US.wdb";
     static final String STATION_PAR = "station_par";
+    static final String ROMEDLL = "RomeDLL.dll";
 
     //
 //    private String binDir = Config.getString("m.bin.dir", "/tmp/csip/bin");

web/META-INF/csip-conf.json

@@ -1,4 +1,5 @@
 {
-    "csip-erosion.version": "$version: 0.2.58 69132821319e 2016-05-11 wlloyd@titan, built at 2016-05-11 13:04 by wlloyd$",
-    "weps.version" : "1.3.9"
+    "csip-erosion.version": "$version: 0.2.59 eb5986b2c844 2016-05-11 wlloyd@titan, built at 2016-05-13 17:28 by wlloyd$",
+    "weps.version" : "1.3.9",
+    "csip.home" : "/tmp/csip"
 }