Search in sources :

Example 1 with InstallStatus

use of cbit.vcell.resource.PythonSupport.InstallStatus in project vcell by virtualcell.

the class CopasiServicePython method runCopasiPython.

public static void runCopasiPython(File copasiOptProblemFile, File copasiResultsFile) throws IOException {
    // It's 2015 -- forward slash works for all operating systems
    File PYTHON = PythonSupport.getPythonExe();
    InstallStatus copasiInstallStatus = PythonSupport.getPythonPackageStatus(PythonPackage.COPASI);
    if (copasiInstallStatus == InstallStatus.FAILED) {
        throw new RuntimeException("failed to install COPASI python package, consider re-installing VCell-managed python\n ...see Preferences->Python->Re-install");
    }
    if (copasiInstallStatus == InstallStatus.INITIALIZING) {
        throw new RuntimeException("VCell is currently installing or verifying the COPASI python package ... please try again in a minute");
    }
    File vcellOptDir = ResourceUtil.getVCellOptPythonDir();
    File optServicePythonFile = new File(vcellOptDir, "optService.py");
    if (PYTHON == null || !PYTHON.exists()) {
        throw new RuntimeException("python executable not specified, set python location in VCell menu File->Preferences...->Python Properties");
    }
    String[] cmd = new String[] { PYTHON.getAbsolutePath(), optServicePythonFile.getAbsolutePath(), copasiOptProblemFile.getAbsolutePath(), copasiResultsFile.getAbsolutePath() };
    IExecutable exe = prepareExecutable(cmd);
    try {
        exe.start(new int[] { 0 });
        if (exe.getExitValue() != 0) {
            throw new RuntimeException("copasi python solver (optService.py) failed with return code " + exe.getExitValue() + ": " + exe.getStderrString());
        }
    } catch (ExecutableException e) {
        e.printStackTrace();
        throw new RuntimeException("optService.py invocation failed: " + e.getMessage(), e);
    }
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) InstallStatus(cbit.vcell.resource.PythonSupport.InstallStatus) File(java.io.File) IExecutable(org.vcell.util.exe.IExecutable)

Example 2 with InstallStatus

use of cbit.vcell.resource.PythonSupport.InstallStatus in project vcell by virtualcell.

the class VtkServicePython method writeVtkGridAndIndexData.

private void writeVtkGridAndIndexData(String visMeshType, VisMesh visMesh, String domainName, File vtkFile, File indexFile) throws IOException {
    if (lg.isDebugEnabled()) {
        lg.debug("writeVtkGridAndIndexData (python) for domain " + domainName);
    }
    File PYTHON = PythonSupport.getPythonExe();
    InstallStatus copasiInstallStatus = PythonSupport.getPythonPackageStatus(PythonPackage.VTK);
    if (copasiInstallStatus == InstallStatus.FAILED) {
        throw new RuntimeException("failed to install VTK python package, consider re-installing VCell-managed python\n ...see Preferences->Python->Re-install");
    }
    if (copasiInstallStatus == InstallStatus.INITIALIZING) {
        throw new RuntimeException("VCell is currently installing or verifying the VTK python package ... please try again in a minute");
    }
    String baseFilename = vtkFile.getName().replace(".vtu", ".visMesh");
    File visMeshFile = new File(vtkFile.getParentFile(), baseFilename);
    VisMeshUtils.writeVisMesh(visMeshFile, visMesh);
    File vtkServiceFile = new File(ResourceUtil.getVCellVTKPythonDir(), "vtkService.py");
    // It's 2015 -- forward slash works for all operating systems
    String[] cmd = new String[] { PYTHON.getAbsolutePath(), vtkServiceFile.getAbsolutePath(), visMeshType, domainName, visMeshFile.getAbsolutePath(), vtkFile.getAbsolutePath(), indexFile.getAbsolutePath() };
    IExecutable exe = prepareExecutable(cmd);
    try {
        exe.start(new int[] { 0 });
        if (exe.getExitValue() != 0) {
            throw new RuntimeException("mesh generation script for domain " + domainName + " failed with return code " + exe.getExitValue() + ": " + exe.getStderrString());
        }
    } catch (ExecutableException e) {
        e.printStackTrace();
        throw new RuntimeException("vtkService.py invocation failed: " + e.getMessage(), e);
    }
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) InstallStatus(cbit.vcell.resource.PythonSupport.InstallStatus) File(java.io.File) IExecutable(org.vcell.util.exe.IExecutable)

Aggregations

InstallStatus (cbit.vcell.resource.PythonSupport.InstallStatus)2 File (java.io.File)2 ExecutableException (org.vcell.util.exe.ExecutableException)2 IExecutable (org.vcell.util.exe.IExecutable)2