Package winterwell.utils

Examples of winterwell.utils.Process.waitFor()


  public static List<String> getMyIP() {
    if (Utils.OSisUnix()) {
      Process p = new Process("ifconfig");
      try {
        p.run();
        p.waitFor(2000);
        String out = p.getOutput();
        Matcher m = IP4_ADDRESS.matcher(out);
        ArrayList<String> ips = new ArrayList<String>();
        while (m.find()) {
          ips.add(m.group());
View Full Code Here


      Process p = new Process("wkhtmltopdf "
          + (waitFor == null ? "" : waitFor) + " "
          + temp1.getAbsolutePath() + " " + file.getAbsolutePath());
      p.setEcho(true);
      p.run();
      int done = p.waitFor(TUnit.MINUTE.getMillisecs());

      if (!file.exists())
        throw new IOException("Failed to create " + file + "\t"
            + p.getError());
      if (p.getOutput().contains("cannot connect to X server")
View Full Code Here

      // 2. Render, trim and convert to PNG with convert
      Process p2 = new Process("convert -trim -antialias -density 300 "
          + temp1.getAbsolutePath() + " " + file.getAbsolutePath());
      p2.run();
      p2.waitFor(TUnit.MINUTE.getMillisecs());

      if (!file.exists())
        throw new IOException("Failed to create " + file + "\t"
            + p2.getError());
    } catch (Exception e) {
View Full Code Here

      if (Utils.getOperatingSystem().contains("linux")
          || Utils.getOperatingSystem().contains("unix")) {
        String path = file.getAbsolutePath();
        Process p = new winterwell.utils.Process("rm -f " + path);
        p.run();
        p.waitFor(1000);
        if (!file.exists())
          return;
        throw new WrappedException(new IOException(
            "Could not delete file " + file + "; " + p.getError()));
      }
View Full Code Here

    if (!Utils.OSisUnix())
      throw new TodoException("" + out);
    Process p = new winterwell.utils.Process("rm -f "
        + out.getAbsolutePath());
    p.run();
    int ok = p.waitFor();
    if (ok != 0)
      throw new IORException(p.getError());
  }

  public static String filenameDecode(String name) {
View Full Code Here

    if (!returnIP && IP4_ADDRESS.matcher(site).matches()) {
      x = "-x ";
    }
    Process p = new Process("dig +short " + x + site);
    p.run();
    p.waitFor(5000); // this should be fast -- 5 seconds allows aeons of
              // time
    String out = p.getOutput();

    // look for an IPv4 address?
    if (returnIP) {
View Full Code Here

    try {
      final File md = File.createTempFile("tmp", ".md");
      FileUtils.write(md, text);
      Process process = new Process(cmd+" "+md.getAbsolutePath());
      process.run();
      int ok = process.waitFor(10000);
      if (ok != 0) throw new FailureException(cmd+" failed:\n"+process.getError());
      String html = process.getOutput();
      FileUtils.delete(md);
      return html;
    } catch (Exception e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.