[IronPython] Redirecting input/output in IronPython 2.x

JoeSox joesox at gmail.com
Tue May 27 01:58:22 CEST 2008


Sweet, that appears to have worked.
Thanks!

-Joe
On 5/26/08, Paul Turbett <sls at iinet.net.au> wrote:
> Try SourceCodeKind.SingleStatement in the call to
> CreateScriptScopeFromString.
>
> L8r, Paul
>
>
> JoeSox wrote:
> Dino,

This way is not playing well with an overriding System.IO.Stream
> class
I have written. I set SetOutput with this class which has a
> delegate
listening for the output. I do 'source.Execute(scope);' but it
> doesn't
seem to be doing the same thing as ExecuteToConsole (flushing).
> Any
ideas on what the difference is?
In IP1.1 I used to use ExecuteToConsole
> and the output stream was updated.

Here is some of the basic code I am
> using to give some better idea on
what I am talking
> about:
-------------------------------------
public
> ScriptEngine engine =
> ScriptRuntime.Create().GetEngine("py");
public ScriptScope
> scope;
scope = engine.CreateScope();

//IPEStreamWrapper:Stream, and take
> delegate
> IPEngineResponse
engine.Runtime.IO.SetOutput(new
ITB2.IPEWrapper.IPEStreamWrapper(IPEWrapper.IPEStreamWrapper.IPEngineResponse),
engine.Runtime.IO.InputEncoding);
>
ScriptSource source =
> engine.CreateScriptSourceFromString(command,
SourceCodeKind.Expression);
object
> o =
> source.Execute(scope);

IPEStreamWrapper.sbOutput.ToString();
> //nothing, I don't see any
MemoryStream Flushing in IPEStreamWrapper Stream
> class
-------------------------------------

Thanks,
> Joe

On 4/17/08, Dino Viehland <dinov at exchange.microsoft.com> wrote:

>
You
> want
ScriptRuntime.IO.SetOutput/ScriptRuntime.IO.SetError
> which
will let you set the I/O used for all the ScriptEngine's running in
> the
given ScriptRuntime. You also now need to provide either a Stream and
> an
Encoding or a Stream and a TextWriter. The reason for that is to
> support
both text and binary output for scenarios such as PHP wanting to
> print a
JPG.




From:
> users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com]
> On Behalf Of
David Seruyange
Sent: Thursday, April 17, 2008 10:59 AM
To:
> IronPython IronPython
Subject: [IronPython] Redirecting input/output in
> IronPython 2.x





Hey everyone,

looking at a lot of the samples online I
> see the following:

 pythonEngine.SetStandardError(s);


>  pythonEngine.SetStandardOutput(s);

> where s is some stream. The Python Engine doesn't seem to support
> that
method when I make a reference to IronPython 2.0. Am I missing
> something or
are the online resources now obsolete?

Thanks much
> -

David


________________________________


Be a better
> friend, newshound, and know-it-all with Yahoo! Mobile. Try
> it
now.
_______________________________________________
Users
> mailing
> list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


>

>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list