I think you should consider running a process in background python web2py.py -S yourapp -M -R yourscript
for more info: python web2py.py -h and run the shell commands from "yourscript". Then just have the web interface display the output of your script as it is generated. Massimo On Feb 12, 5:55 am, Cro <prah...@gmail.com> wrote: > Good day. > I discovered web2py a few weeks ago. I like it because it's light and > powerful. :) And the templating system is excellent. > I played with it a little. I worked in PHP and Karrigell before, so i > know a little about web servers. > > Ok, straight to point. > > I use windows. I am trying to make a local server for running some > automations. (that is, receive raw data from customers, move files > from one place to another on the server, process data, compress the > input and output files and send output data to customers. All is done > automatically, via some batch files / python scripts) > > What i want is this : to create some kind of forum, with local area > network access only, user / password access. > Then, i want to call the scripts i defined (batch or python) from > web2py and render in browser the messages that i receive while the > automation process happens... > > I started to broadcast on LAN, port 80. I tested something. On a new > page i defined : > > def index(): > import os > content = "Starting<br>\n" > > os.system('pause') > > content += "The end<br>" > return dict( content=XML(content) ) > > I hope you are not laughing :)) > I checked index page from a client. The page was suspended in client > browser, and on the server there was one cmd window "Press any key to > continue". I had to close the cmd window for the page to completely > load. The other pages were working just fine even when the index page > was locked, i was very pleased to see that. :) > > Now, i cannot work with os.system() calls, because i don't have the > control i need. I don't know how to catch the messages from the > program i am running with os.system. I don't need return the codes, i > want full messages. > So i used another example : > > import os > import subprocess as _sproc > from subprocess import PIPE > content = "Starting<br>\n" > > p = _sproc.Popen( 'c:web2py/ccc.bat', bufsize=-1, stdout=PIPE, > stderr=PIPE, shell=True ).communicate() > retcode = p[0].replace('\r\n', '<br>\n') + '<br>' > content += retcode > > content += "The end<br>" > return dict( content=XML(content) ) > > The file "ccc.bat" contained: > @ECHO OFF > > ECHO AA AAA > ECHO BB BBB > > pause > > I was pleased to see that the execution was imediate and the server > didn't lock. :) > > I also tested the same app with a more complex automation. The > respective page and script freezes completely while the long > application communicates, but the rest of pages work fine. > > I am very happy with web2py. > > Can anyone suggest any improvements i can do? Maybe run my > applications in a different manner, so that the rest of the functions > included in the script will work while automation communicates? > Maybe refresh the page with each message printed, so that i don't have > to wait for the whole process to finish before i can see the > result?... I don't know how to do that yet. > > Thank you. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---