Click here to Skip to main content
15,891,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need to enable a way to continuously communicate between test program (C#) and python interpreter to be able to send commands or scripts to the interpreter during the test program flow.




Example :

Python manager should be able to start the python process or multiple python processes

Python manager should be able to track all python processes by name/process ID

 example: 

    Python.Start("ThisProcessIsPyval") ---> Starts the process, with Name tracked by the object (like the TCPIP handlername concept)

    Python.Start("ThisProecssisXray") --> Starts the process, tracked as "ThisProcessIsXray" 


Be able to terminate the process by name/PIDs 

    Python.Terminate("ThisProcessIsPyval") --> Ends the Process



Be able to send direct python commands, and return stdout results
 example: Python.Send("ThisPyisPyval", <command>) where command is "print("hello world")"



be able to execute a python script (when given the absolute path), and return script output in stdout

 example: Python.Script("ThisPyisPyval", <path_to_script>) where script is pythonscript.py located at c:\python\scripts\slt



Be able to run multiple commands through a Python process / Python CLI


What I have tried:

I need your guidance, How do i do?
Posted
Comments
Richard MacCutchan 4-Jul-22 6:51am    
Sorry but that question is far too wide for a quick answers forum. We do not have the time or space to provide a complete project design. I have never seen the "Python.Start" command, so can only assume it is something that you have written.
HelpMewithCode 4-Jul-22 7:43am    
Hi Rechard MacCutchan thank you for the reply ,

Just forgot about above line its just feature .
My general questions is i have test program in c# , i need to send the command through C# to python and run into the python interpreter , So how do i implement this?If you could help it will great full
Richard MacCutchan 4-Jul-22 7:51am    
There are various methods but they will depend on exactly what you are trying to do. Your C# code could use the Process Clas[^] to start a Python program. You could use sockets to communicate between the C# and Python applications. You could use some shared file to pass information between the two. So basically, you need to do some research into the available technologies to decide which would be best to investigate in depth.
HelpMewithCode 4-Jul-22 11:12am    
Yes Exactly I thought to do socket communication between c# and python interpreter and send the command through the c# which will be executed in python interpreter n return .


Richard McCutchen have you work on any project concept of same .
How do I connect c# and python interpreter via sockets ?
Could you guide me
if possible i will connect you personally .
HelpMewithCode 5-Jul-22 2:20am    
Do you any example Richard McCutchen?
Which i can start my project

please help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900