[IronPython] Talk to Python script from C# app...

Bob Rosembob brosembob at yahoo.com
Wed Jun 11 15:40:34 PDT 2008


Thank you Michael and Curt for your quick response. 
I got the script working using the following logic:
 
private
...ProcessP;
P = 
P.OutputDataReceived += 
P.ErrorDataReceived += 
P.StartInfo.UseShellExecute = 
P.StartInfo.RedirectStandardOutput = 
P.StartInfo.RedirectStandardError = 
P.StartInfo.CreateNoWindow = 
P.StartInfo.FileName = @python.ToString();
P.StartInfo.Arguments = 
P.Start();
P.BeginOutputReadLine();
P.BeginErrorReadLine();stringpython = @"C:\Python25\python.exe";stringpyscript = @"IronPython\cycle_LR.py";newProcess();newDataReceivedEventHandler(OnOutputDataReceived);newDataReceivedEventHandler(OnErrorReceived);false;true;true;true;"-u "+ pyscript.ToString() + @" IronPython\cycle.ini";
 
As you probably guessed I installed latest Python 2.5.2 on my machine. 
Now, do I need to include Python 2.5.2 into my deployment package and install it on the user's PC or I can some how embed it into my application?
 
>>If the former then you can use System.Process to launch the script with 
>>IronPython. You will need to download (rather than install) and launch 
>>the script with 'ipy.exe args...'.
 
Wouldn't this approach be simpler, since I don't have to install python on user's PC? How exactly can I run ipy.exe with the args?

Curt, 
The script that I have to use was created in 2004 and probably was not tested with IronPython. The guy who created it left the company and nobody modified the script since.

Thank you very much,
Bob
 
 
----- Original Message ----
From: Michael Foord <fuzzyman at voidspace.org.uk>
To: Discussion of IronPython <users at lists.ironpython.com>
Sent: Wednesday, June 11, 2008 1:29:27 PM
Subject: Re: [IronPython] Talk to Python script from C# app...

Hello Bob,

The question is, do you want to run it in the same way you would launch 
any command line application from C# and collect the results from 
standard out - or do you want to embed IronPython and run the script 
'inside' your application?

If the former then you can use System.Process to launch the script with 
IronPython. You will need to download (rather than install) and launch 
the script with 'ipy.exe args...'.

If the latter then how you do it depends on whether you use IronPython 1 
or 2 and what exactly your use case is.

Michael Foord
http://www.ironpythoninaction.com/

Bob Rosembob wrote:
> Hello there,
> I have a C# application and a 3rd party Python script that the 
> application should run. The script is called periodical with some 
> arguments, performs some calculations and returns the results. I'm 
> running Vista & VS2005.
>  
> What should I do to run the script from my application? I assume I 
> need to install IronPython on my PC. How exactly should I do it?
>  
> Thanks for your help.
>  
> Bob
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20080611/a59aef25/attachment.htm>


More information about the Users mailing list