On Jul 2, 3:40 pm, Brian <[EMAIL PROTECTED]> wrote:
> Sorry I should have been more clear..The script generate many many
> lines of prints, and the results are nested among many classes and
> functions that get called, so it'd be difficult to do a simple return
> Response() to capture all of the output generated.
Sounds like your scripts need to be run to produce output. You could
try something like
import commands
cmd = 'ls -l'
outtext = commands.getoutput(cmd)
return Response(outtext)
If you're using Windows (or want to control stdout or stderr), look at
the docs for the subprocess module in the standard library.
http://www.python.org/doc/current/lib/module-commands.html
http://www.python.org/doc/current/lib/module-subprocess.html
If you can import your scripts and run them by calling a function or
instantiating a class, you could try redirecting stdout to a StringIO
object and do something like
>>> import sys
>>> from cStringIO import StringIO
>>> stdout_saved = sys.stdout
>>> f = StringIO()
>>> sys.stdout = f
>>> def test_output():
... print 'abcd'
...
>>> test_output()
>>> sys.stdout = stdout_saved
>>> f.getvalue()
'abcd\n'
--David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---