private void openProcess() { if (process != null) error("openProcess called but process is already open."); String processNames[] = {"python2.7", "python", "python2.7.exe", "python.exe"}; final String ENV_VAR = "HYST_PYTHON_PATH"; String loc = null; for (String processName : processNames) { try { loc = FileOperations.locate(processName, processName, ENV_VAR); Hyst.log("Using python process at path: " + loc); break; } catch (FileNotFoundException e) { Hyst.log(e.getMessage()); } } if (loc == null) error( "Error starting python process. Is 'python2.7' or 'python' on your PATH or " + ENV_VAR + "?"); ProcessBuilder pb = new ProcessBuilder(loc, "-i"); String workingDir = getJarBaseDirectory(); pb.directory(new File(workingDir)); try { process = pb.start(); } catch (IOException e) { error("Exception while starting python process: " + e.toString()); } stdout = new BufferedReader(new InputStreamReader(process.getInputStream())); stderr = new BufferedReader(new InputStreamReader(process.getErrorStream())); stdin = new OutputStreamWriter(process.getOutputStream()); }
@Override protected void printAutomaton() { this.ha = (BaseComponent) config.root; if (config.forbidden.size() == 0) { Hyst.log( "HyComp Printer: using initial states as forbidden states since forbidden states are not defined in model."); config.forbidden = config.init; } // remove this after proper support for multiple initial modes is added if (config.init.size() != 1) throw new AutomatonExportException( "Printer currently only supports single-initial-state models"); // else if (ha.forbidden.size() != 1) // throw new AutomatonExportException("Printer currently only supports single-forbidden-state // models"); // transform resets to include identity expressions new AddIdentityResetPass().runTransformationPass(config, null); printDocument(originalFilename); }
/** * Close the process (if needed), and raise an error * * @param description the error description */ private void error(String description) { Hyst.logDebug(description); close(); throw new AutomatonExportException(description); }
private static void logDebug(String description) { Hyst.logDebug(description); }