Package helper

Examples of helper.ProcessHandler$ProcessWatcher


        String sMakeFile = sUnoapi + sep + "makefile.mk";
        File fMakeFile = new File(sMakeFile);
        assure("ERROR: could not find makefile: '" + sMakeFile + "'", fMakeFile.exists(), mContinue);

        String[] cmdLines = getCmdLines(sUnoapi);
        ProcessHandler procHdl = runShellCommand(cmdLines, fUnoapi, false);
        if (mDebug) {
            log.println("---> Output of dmake:");
            log.println(procHdl.getOutputText());
            log.println("<--- Output of dmake file:");
            log.println("---> Error output of dmake file");
            log.println(procHdl.getErrorText());
            log.println("<--- Error output of dmake file");
        }
        assure("module failed", verifyOutput(procHdl.getOutputText()), mContinue);

        log.println("kill existing office...");
        try {
            officeProvider.closeExistingOffice(param, true);
        } catch (java.lang.UnsatisfiedLinkError exception) {
View Full Code Here


            cmdLines = new String[]{shell, "/C ", cmd + " ^ echo SRC_ROOT=%SRC_ROOT"};
        } else {
            cmdLines = new String[]{shell, "-c ", cmd + " ; echo \"SRC_ROOT=$SRC_ROOT\""};
        }

        ProcessHandler procHdl = runShellCommand(cmdLines, null, true);
        if (mDebug) {
            log.println("---> Output of command:");
            log.println(procHdl.getOutputText());
            log.println("<--- Output of command:");
            log.println("---> Error output of command");
            log.println(procHdl.getErrorText());
            log.println("<--- Error output of command");
        }
        String output = procHdl.getOutputText();
        String[] outs = output.split("\n");

        for (int i = 0; i < outs.length; i++) {
            String line = outs[i];
            if (line.startsWith("SRC_ROOT")) {
View Full Code Here

    private ProcessHandler runShellCommand(String[] cmdLines, File workDir, boolean shortWait) {

        boolean changedText = true;
        int count = 0;
        String memText = "";
        ProcessHandler procHdl = new ProcessHandler(cmdLines, (PrintWriter) log, workDir);
        procHdl.executeAsynchronously();
        int timeOut = 0;

        if (shortWait) {
            timeOut = 3000;
        } else {
            timeOut = param.getInt(PropertyName.TIME_OUT) / 2;
        }

        OfficeWatcher ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER);

        while (changedText && !procHdl.isFinished()) {
            count++;
            if (ow != null) {
                ow.ping();
            }
            log.println("CheckModuleAPI: waiting... " + count);
            utils.shortWait(timeOut);
            if (ow != null) {
                ow.ping();
            }
            // check for changes in the output stream. If there are no changes, the process maybe hangs
            if (procHdl.getOutputText().equals(memText)) {
                changedText = false;
            }
            memText = procHdl.getOutputText();
        }

        if (!procHdl.isFinished()) {
            log.println("Process ist not finished but there are no changes in output stream.");
        }
        return procHdl;
    }
View Full Code Here

        String sMakeFile = sUnoapi + sep + "makefile.mk";
        File fMakeFile = new File(sMakeFile);
        assure("ERROR: could not find makefile: '" + sMakeFile + "'", fMakeFile.exists(), mContinue);

        String[] cmdLines = getCmdLines(sUnoapi);
        ProcessHandler procHdl = runShellCommand(cmdLines, fUnoapi, false);
        if (mDebug) {
            log.println("---> Output of dmake:");
            log.println(procHdl.getOutputText());
            log.println("<--- Output of dmake file:");
            log.println("---> Error output of dmake file");
            log.println(procHdl.getErrorText());
            log.println("<--- Error output of dmake file");
        }
        assure("module failed", verifyOutput(procHdl.getOutputText()), mContinue);

        log.println("kill existing office...");
        try {
            officeProvider.closeExistingOffice(param, true);
        } catch (java.lang.UnsatisfiedLinkError exception) {
View Full Code Here

            cmdLines = new String[]{shell, "/C ", cmd + " ^ echo SRC_ROOT=%SRC_ROOT"};
        } else {
            cmdLines = new String[]{shell, "-c ", cmd + " ; echo \"SRC_ROOT=$SRC_ROOT\""};
        }

        ProcessHandler procHdl = runShellCommand(cmdLines, null, true);
        if (mDebug) {
            log.println("---> Output of command:");
            log.println(procHdl.getOutputText());
            log.println("<--- Output of command:");
            log.println("---> Error output of command");
            log.println(procHdl.getErrorText());
            log.println("<--- Error output of command");
        }
        String output = procHdl.getOutputText();
        String[] outs = output.split("\n");

        for (int i = 0; i < outs.length; i++) {
            String line = outs[i];
            if (line.startsWith("SRC_ROOT")) {
View Full Code Here

    private ProcessHandler runShellCommand(String[] cmdLines, File workDir, boolean shortWait) {

        boolean changedText = true;
        int count = 0;
        String memText = "";
        ProcessHandler procHdl = new ProcessHandler(cmdLines, (PrintWriter) log, workDir);
        procHdl.executeAsynchronously();
        int timeOut = 0;

        if (shortWait) {
            timeOut = 3000;
        } else {
            timeOut = param.getInt(PropertyName.TIME_OUT) / 2;
        }

        OfficeWatcher ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER);

        while (changedText && !procHdl.isFinished()) {
            count++;
            if (ow != null) {
                ow.ping();
            }
            log.println("CheckModuleAPI: waiting... " + count);
            utils.shortWait(timeOut);
            if (ow != null) {
                ow.ping();
            }
            // check for changes in the output stream. If there are no changes, the process maybe hangs
            if (procHdl.getOutputText().equals(memText)) {
                changedText = false;
            }
            memText = procHdl.getOutputText();
        }

        if (!procHdl.isFinished()) {
            log.println("Process ist not finished but there are no changes in output stream.");
        }
        return procHdl;
    }
View Full Code Here

    void checkExistance(String _sScriptFile, String _sName)
        {
            boolean bBackValue = false;
            // Process testshl = Runtime.getRuntime().exec(scriptFile);
            ProcessHandler aHandler = new ProcessHandler(_sScriptFile);
            bBackValue = aHandler.executeSynchronously();
            TimeHelper.waitInSeconds(1, "wait after ProcessHandler.executeSynchronously()");

            StringBuffer aBuffer = new StringBuffer();
            aBuffer.append(aHandler.getErrorText()).append(aHandler.getOutputText());
            String sText = aBuffer.toString();

            if (sText.length() == 0)
            {
                String sError = "Must quit. " + _sName + " may be not accessable.";
View Full Code Here

     * Get the process ID from the Office
     * @return the Id as String
     */
    private String getOfficeProcessID() {
        writeExecutableFile(sProcessIdCommand, sProcessId);
        ProcessHandler processID = new ProcessHandler(sProcessIdCommand);
        processID.executeSynchronously();
        String text = processID.getOutputText();
        if (text == null || text.equals("") || text.indexOf(' ') == -1)
            failed("Could not determine Office process ID. Check " + sProcessIdCommand);
        StringTokenizer aToken = new StringTokenizer(text);
        // this is not nice, but ps gives the same output on every machine
        aToken.nextToken();
View Full Code Here

     * @return The memory used by the Office.
     */
    private int getOfficeMemoryUsage() {
        String command = sMemoryMonitor.replaceAll("<processID>", getOfficeProcessID());
        writeExecutableFile(sOfficeMemoryCommand, command);
        ProcessHandler processID = new ProcessHandler(sOfficeMemoryCommand);
        processID.executeSynchronously();
        String text = processID.getOutputText();
        if (text == null || text.equals("") || text.indexOf(' ') == -1) {
            failed("Could not determine Office memory usage. Check " + sOfficeMemoryCommand);
        }
        StringTokenizer aToken = new StringTokenizer(text);
        // this works, because the output of pmap is quite standardized.
View Full Code Here

            PrintWriter fWriter = new PrintWriter(new FileWriter(fileName));
            fWriter.println(bash);
            fWriter.println(line);
            fWriter.close();
            // change rights to rwxrwxrwx
            ProcessHandler processID = new ProcessHandler(sChmod + fileName);
            processID.executeSynchronously();
        }
        catch(java.io.IOException e) {
        }
    }
View Full Code Here

TOP

Related Classes of helper.ProcessHandler$ProcessWatcher

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.