Package er.extensions.foundation.ERXRuntimeUtilities

Examples of er.extensions.foundation.ERXRuntimeUtilities.Result


            String dot = response.contentString();
            File f = null;
            try {
                f = File.createTempFile("GVTemp", "dot");
                ERXFileUtilities.stringToFile(dot, f);
                Result result = ERXRuntimeUtilities.execute(new String[] { "/usr/local/bin/dot", "-T" + format, "", f.getAbsolutePath() }, null, null, 0);
                response.setContent(new NSData(result.getResponse()));
                if (format.equals("svg")) {
                    response.setHeader("image/svg+xml", "content-type");
                } else if (format.equals("pdf")) {
                    response.setHeader("application/pdf", "content-type");
                } else {
View Full Code Here


    String[] imageMagickCommands = imageMagickCommandList.toArray(new String[imageMagickCommandList.size()]);

    try {
      System.out.println("ImageMagickProcessor.processImage: " + imageMagickCommandList);
      Result result = ERXRuntimeUtilities.execute(imageMagickCommands, null, null, 0);
      int exitValue = result.getExitValue();
      if (exitValue != 0) {
        log.warn("Warning: ImageMagick convert returned with a value of " + exitValue + ", error = " + result.getErrorAsString());
      }
    }
    catch (Exception e) {
      IOException ioex = new IOException("ImageMagick failed.");
      ioex.initCause(e);
      throw ioex;
    }

    if (watermarkFile != null) {
      List<String> watermarkCommandList = new LinkedList<String>();
      watermarkCommandList.add(_imageMagickCompositeBinary.getAbsolutePath());

      watermarkCommandList.add("-watermark");
      watermarkCommandList.add("100%");

      if (tileWatermark) {
        watermarkCommandList.add("-tile");
      }

      watermarkCommandList.add(watermarkFile.getAbsolutePath());
      watermarkCommandList.add(outputFile.getAbsolutePath());
      watermarkCommandList.add(outputFile.getAbsolutePath());

      String[] watermarkCommands = watermarkCommandList.toArray(new String[watermarkCommandList.size()]);

      try {
        Result result = ERXRuntimeUtilities.execute(watermarkCommands, null, null, 0);
        int exitValue = result.getExitValue();
        if (exitValue != 0) {
          log.warn("Warning: ImageMagick composite returned with a value of " + exitValue + ", error = " + result.getErrorAsString());
        }
      }
      catch (Exception e) {
        IOException ioex = new IOException("ImageMagick was interrupted.");
        ioex.initCause(e);
View Full Code Here

      commands.add(inputFile.getCanonicalPath());
     
      commands.add("--out");
      commands.add(outputFile.getCanonicalPath());

      Result result = ERXRuntimeUtilities.execute(commands.toArray(new String[commands.size()]), null, null, 30000);
      if (result.getExitValue() != 0) {
        throw new RuntimeException("Sips exited with the exit code #" + result.getExitValue());
      }
    }
    catch (Throwable t) {
      throw new IOException("Failed to thumbnail image: " + t.getMessage() + " (also, Java 1.5 is stupid!)");
    }
View Full Code Here

        }
        if (ERXStringUtilities.stringIsNullOrEmpty(dir)) {
            dir = "/";
        }
        try {
            Result result = ERXRuntimeUtilities.execute(commandArray, envpArray, new File(dir), timeout);
            String response = result.getResponseAsString();
            consoleText = "\n" + response;
            consoleTextHistory += "\n";
            consoleTextHistory += "\n";
      consoleTextHistory += "<b>"+command+"</b>";
            consoleTextHistory += "\n";
View Full Code Here

        args.addObject(((srcHost != null) ? (srcHost + ":") : "") + srcPath);
        args.addObject(((dstHost != null) ? (dstHost + ":") : "") + dstPath);

        String[] cmd = ERXArrayUtilities.toStringArray(args);
        try {
            Result result = ERXRuntimeUtilities.execute(cmd, null, null, 0L);
            if(result.getExitValue() != 0) {
                throw new IOException("Unable to remote copy file: (exit status = " + result.getExitValue() + ") " + result.getErrorAsString() + "\n");
            }
        } catch (TimeoutException e) {
            throw new IOException("Command timed out");
        }
   }
View Full Code Here

public class ERXRuntimeUtilitiesTest extends ERXTestCase {

  public void testExecuteMultipleFastCommands() throws IOException, TimeoutException {
    for (int i = 0; i < 100; ++i) {
        Result result = ERXRuntimeUtilities.execute(new String[] {"echo", String.valueOf(i)}, null, null, 0);
        assertEquals(i + "\n", result.getResponseAsString());
    }
  }
View Full Code Here

TOP

Related Classes of er.extensions.foundation.ERXRuntimeUtilities.Result

Copyright © 2018 www.massapicom. 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.