T_10.java [src/java/m/rusle2] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package m.rusle2;
import csip.api.server.Executable;
import csip.ModelDataService;
import csip.api.server.ServiceException;
import csip.annotations.Description;
import csip.annotations.Name;
import csip.annotations.Resource;
import static csip.annotations.ResourceType.REFERENCE;
import java.util.logging.Level;
import javax.ws.rs.Path;
import org.apache.commons.io.FileUtils;
/**
*
* @author od
*/
@Name("Test wine")
@Description("IET / pyrome version of R2; RomeDLL 2.5.2.11; references NRCS Soil Data Mart")
//@Path("m/t/1.0")
@Resource(type = REFERENCE, file = "cmd.exe", wine = true, id = "cmd")
public class T_10 extends ModelDataService {
@Override
protected void doProcess() throws Exception {
Executable python = resources().getExe("cmd");
python.setArguments("/C", "dir", ".");
LOG.info("Executing pyrome rusle2");
int ret = python.exec();
if (ret != 0) {
String stderr = FileUtils.readFileToString(python.stderr());
throw new ServiceException("RUSLE 2 PYTHON error: error executing pyrome:" + stderr);
}
// String runrusle2 = "winetricks vd=off ; wine /home/ubuntu/.wine/drive_c/Python34/python.exe rusle2csip.py\n";
String stdout = "\n" + FileUtils.readFileToString(python.stdout());
if (LOG.isLoggable(Level.INFO)) {
LOG.info("stdout: " + stdout);
LOG.info("exit val: " + ret);
}
}
}