This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Execute a python script from Symfony

Discuss Symfony 2 bundles here

Execute a python script from Symfony

by Azeann » Mon May 05, 2014 11:45 am

Hi everyone,

I'm developing a web application with Symfony2 for the first time. I have a form and a python script. I need to execute the python script with the values filled in the form. For example, the user enter his file, I execute my script on this file and I return the results in files that the user can download.
I wanted to know what is the best way to do this properly ? Do I have to create a Service or something like that ? Will I use the exec() function ?
Another (maybe stupid) question, where do I put my python script in the Symfony application ?

Thanks in advance for your answer !

Aze'
Azeann
Junior Member
 
Posts: 1
Joined: Mon May 05, 2014 11:30 am

Re: Execute a python script from Symfony

by Asperon » Tue Jun 03, 2014 10:01 pm

I think the best way to approach any external script would be to use the process component built into symfony: http://symfony.com/doc/current/components/process.html

How you organize it can vary honestly. You can drop the code you need right into the controller, or if you are maybe going to run different external scripts at different times in different places, you could create a service that you can call from any controller. But if it is a one time thing, you can just place the code in the controller.
Asperon
Junior Member
 
Posts: 4
Joined: Tue Jun 03, 2014 1:50 am

Re: Execute a python script from Symfony

by zohaa » Thu Nov 20, 2014 1:09 pm

cannot see what is the trouble with my comment table which right to exist cannot be denied !
Help would be appreciated.
Thanks in advance.
Get fast success in 642-996 and testking exam questions by using Testking.net.We also offer nova and www.kumc.edu for your prep of Florida National University.
zohaa
Junior Member
 
Posts: 1
Joined: Thu Nov 20, 2014 1:05 pm