Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tcf-dev] Reading the process output in TE

Hi Anna,

> > I've added a small unit test covering this scenario as
> org.eclipse.tcf.te.tests.tcf.processes.launcher.ProcessLauncherTestCase. It uses the ProcessLauncher
> directly and reads the process output via a proxy.
> 
> Thanks a lot, it's really helpful! However, I have one question about this test:
> can we use the callback mechanism in the launcher.launch call(right now this argument is null) instead
> of calling waitAndDispatch(5000)?

Sure. In non-unit test code, you would give a callback to the launch(...) method which will be called once the launch is completed. Note that the invocation of the callback does not necessarily mean that the launched process has been terminated already. It only signals that the process got started. The "ProcessContext" object is returned via the callback ( ProcessContext ctx = (ProcessContext)callback.getResult(); )

To listen for the process termination, you can either register a ProcessesListener through the IProcesses service, or you register a event listener (IEventListener) via EventManager.getInstance().addEventListener(...) methods and listen to events of type "ProcessStateChangeEvent". The later one does signal "communication lost" events additional to the "process exited" events.

The waitAndDispatch(...) is necessary only in the unit test, to satisfy the synchronous nature of the unit test execution.

Best regards, Uwe :)


 
> > BTW: Have you any references to ProcessModel.getProcessModel(<peermodel>)? It's on my list to
> do some refactorings there and those wont be API compatible I'm afraid.
> 
> No, I do not atm.
> 
> Thanks for your help!
> Anna.
> 
> >
> >
> >> -----Original Message-----
> >> From: tcf-dev-bounces@xxxxxxxxxxx
> >> [mailto:tcf-dev-bounces@xxxxxxxxxxx] On Behalf Of Anna Dushistova
> >> Sent: Mittwoch, 22. August 2012 10:30
> >> To: TCF Development
> >> Subject: Re: [tcf-dev] Reading the process output in TE
> >>
> >> Hi Uwe,
> >> I would like to use this functionality for, say, running things like
> >> perf and lttng which output has to be parsed before showing it to user.
> >> Or to find out whether gdbserver is ready for connection, see line 126 here:
> >> http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/cross/org.eclip
> >> se.cdt.launch.remote/src/org/eclip
> >> se/cdt/launch/remote/launching/RemoteGdbLaunchDelegate.java
> >>
> >> So if you could provide me with a little unit test that reads the
> >> output of "echo hello", I would really appreciate it.
> >>
> >> Thank a lot for helping me!
> >> Anna.
> >>
> >> On Wed, Aug 22, 2012 at 11:22 AM, Stieber, Uwe <Uwe.Stieber@xxxxxxxxxxxxx> wrote:
> >> > Hi Anna,
> >> >
> >> > The IProcessStreamsProxy is the way to go, yes. On constructing the
> >> > ProcessLauncher, you pass in
> >> the proxy instance which will receive the output. It is not
> >> implemented at the moment because I do not have a direct use case for it, but the
> ProcessLauncher is designed to support it.
> >> >
> >> > Best regards, Uwe :)
> >> >
> >> >
> >> >> -----Original Message-----
> >> >> From: tcf-dev-bounces@xxxxxxxxxxx
> >> >> [mailto:tcf-dev-bounces@xxxxxxxxxxx] On Behalf Of Anna Dushistova
> >> >> Sent: Dienstag, 21. August 2012 13:48
> >> >> To: TCF Development
> >> >> Subject: [tcf-dev] Reading the process output in TE
> >> >>
> >> >> Hi All,
> >> >>
> >> >> The default is to stream the process output to the terminal.
> >> >> However, sometimes it would be nice to be able to launch a command
> >> >> and get the output back without
> >> showing it.
> >> >> I found an IProcessStreamsProxy interface that seems to be
> >> >> suitable for these purposes but there doesn't seem to be anything that implements it.
> >> >> Is it the way to go or is there some other recommended way to achieve what I need?
> >> >>
> >> >> Thanks!
> >> >> Anna.
> >> >> _______________________________________________
> >> >> tcf-dev mailing list
> >> >> tcf-dev@xxxxxxxxxxx
> >> >> http://dev.eclipse.org/mailman/listinfo/tcf-dev
> >> > _______________________________________________
> >> > tcf-dev mailing list
> >> > tcf-dev@xxxxxxxxxxx
> >> > http://dev.eclipse.org/mailman/listinfo/tcf-dev
> >> _______________________________________________
> >> tcf-dev mailing list
> >> tcf-dev@xxxxxxxxxxx
> >> http://dev.eclipse.org/mailman/listinfo/tcf-dev
> > _______________________________________________
> > tcf-dev mailing list
> > tcf-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/tcf-dev
> _______________________________________________
> tcf-dev mailing list
> tcf-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/tcf-dev


Back to the top