Package com.aptana.shared_core.io

Examples of com.aptana.shared_core.io.ThreadStreamReader


                }
                files += "\r";
                monitor.setTaskName("Writing to shell...");

                //No need to synchronize as we'll waitFor() the process before getting the contents.
                ThreadStreamReader inputStream = new ThreadStreamReader(p.getInputStream(), false);
                inputStream.start();
                ThreadStreamReader errorStream = new ThreadStreamReader(p.getErrorStream(), false);
                errorStream.start();

                monitor.worked(1);
                OutputStream outputStream = p.getOutputStream();
                outputStream.write(files.getBytes());
                outputStream.close();

                //We'll read something in the format below:
                //Name                                                                      Stmts   Miss  Cover   Missing
                //-------------------------------------------------------------------------------------------------------
                //D:\workspaces\temp\test_workspace\pytesting1\src\mod1\__init__                0      0   100%  
                //D:\workspaces\temp\test_workspace\pytesting1\src\mod1\a                      10      3    70%   4-6
                //D:\workspaces\temp\test_workspace\pytesting1\src\mod1\hello                   3      3     0%   1-4
                //D:\workspaces\temp\test_workspace\pytesting1\src\mod1\mod2\__init__           5      5     0%   2-8
                //D:\workspaces\temp\test_workspace\pytesting1\src\mod1\mod2\hello2            33     33     0%   1-43
                //-------------------------------------------------------------------------------------------------------
                //TOTAL                                                                        57     50    12%

                monitor.setTaskName("Waiting for process to finish...");
                monitor.worked(1);

                while (true) {
                    try {
                        p.exitValue();
                        break; //process finished
                    } catch (IllegalThreadStateException e) {
                        //not finished
                    }
                    try {
                        Thread.sleep(50);
                    } catch (InterruptedException e) {
                        //ignore
                    }
                    monitor.worked(1);
                    if (monitor.isCanceled()) {
                        try {
                            p.destroy();
                        } catch (Exception e) {
                            Log.log(e);
                        }
                        break;
                    }
                }

                String stdOut = inputStream.getAndClearContents();
                String stdErr = errorStream.getAndClearContents().trim();
                if (stdErr.length() > 0) {
                    Log.log(stdErr);
                }

                monitor.setTaskName("Getting coverage info...(please wait, this could take a while)");
View Full Code Here


            process.getOutputStream().close(); //we won't write to it...
        } catch (IOException e2) {
        }

        //will print things if we are debugging or just get it (and do nothing except emptying it)
        stdReader = new ThreadStreamReader(process.getInputStream());
        errReader = new ThreadStreamReader(process.getErrorStream());

        stdReader.setName("Shell reader (stdout)");
        errReader.setName("Shell reader (stderr)");

        stdReader.start();
View Full Code Here

            }

            monitor.setTaskName("Reading output...");
            monitor.worked(5);
            //No need to synchronize as we'll waitFor() the process before getting the contents.
            ThreadStreamReader std = new ThreadStreamReader(process.getInputStream(), false, encoding);
            ThreadStreamReader err = new ThreadStreamReader(process.getErrorStream(), false, encoding);

            std.start();
            err.start();

            boolean interrupted = true;
            while (interrupted) {
                interrupted = false;
                try {
                    monitor.setTaskName("Waiting for process to finish.");
                    monitor.worked(5);
                    process.waitFor(); //wait until the process completion.
                } catch (InterruptedException e1) {
                    interrupted = true;
                }
            }

            try {
                //just to see if we get something after the process finishes (and let the other threads run).
                Object sync = new Object();
                synchronized (sync) {
                    sync.wait(50);
                }
            } catch (Exception e) {
                //ignore
            }
            return new Tuple<String, String>(std.getContents(), err.getContents());

        } else {
            try {
                throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR,
                        "Error creating process - got null process(" + executionString + ")", new Exception(
View Full Code Here

        FastStringBuffer buf = new FastStringBuffer(s, 0);
        buf.appendN(s, 1000);

        InputStream is = new ByteArrayInputStream(buf.getBytes());
        ThreadStreamReader reader = new ThreadStreamReader(is);
        assertEquals("", reader.getContents());

        reader.start();

        final String expected = buf.toString();
        int i = 0;
        while (!reader.getContents().equals(expected)) {
            i++;
            if (i > 100) {
                assertEquals(expected, reader.getContents());
            }
            waitABit();
        }
        for (i = 0; i < 100; i++) {
            if (!reader.isAlive()) {
                break;
            }
            waitABit();
        }
        assertFalse(reader.isAlive());

    }
View Full Code Here

                    appEngineLocation, new NullProgressMonitor());

            process = run.o1;
            if (process != null) {

                std = new ThreadStreamReader(process.getInputStream());
                err = new ThreadStreamReader(process.getErrorStream());

                std.start();
                err.start();

                outputStream = process.getOutputStream();
View Full Code Here

     * @param process this is the process that was spawned (server for the XML-RPC)
     *
     * @throws MalformedURLException
     */
    public JSConsoleCommunication(int port, Process process, int clientPort) throws Exception {
        stdOutReader = new ThreadStreamReader(process.getInputStream());
        stdErrReader = new ThreadStreamReader(process.getErrorStream());
        stdOutReader.start();
        stdErrReader.start();

        //start the server that'll handle input requests
        this.webServer = new WebServer(clientPort);
View Full Code Here

     * @param process this is the process that was spawned (server for the XML-RPC)
     *
     * @throws MalformedURLException
     */
    public PydevConsoleCommunication(int port, Process process, int clientPort) throws Exception {
        stdOutReader = new ThreadStreamReader(process.getInputStream());
        stdErrReader = new ThreadStreamReader(process.getErrorStream());
        stdOutReader.start();
        stdErrReader.start();

        //start the server that'll handle input requests
        this.webServer = new WebServer(clientPort);
View Full Code Here

            cmdLine = new String[] { TestDependent.JAVA_LOCATION, "-classpath", TestDependent.JYTHON_JAR_LOCATION,
                    "org.python.util.jython", FileUtils.getFileAbsolutePath(f), "" + port, "" + client_port };
        }

        Process process = Runtime.getRuntime().exec(cmdLine);
        err = new ThreadStreamReader(process.getErrorStream());
        out = new ThreadStreamReader(process.getInputStream());
        err.start();
        out.start();

        this.webServer = new WebServer(client_port);
        XmlRpcServer serverToHandleRawInput = this.webServer.getXmlRpcServer();
View Full Code Here

TOP

Related Classes of com.aptana.shared_core.io.ThreadStreamReader

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.