RE: Redirecting STDOUT to a Python Variable

2012-09-27 Thread Prasad, Ramit
Hans Mulder wrote: On 22/09/12 23:57:52, ross.mars...@gmail.com wrote: To capture the traceback, so to put it in a log, I use this import traceback def get_traceback(): # obtain and return the traceback exc_type, exc_value, exc_traceback = sys.exc_info() return

Re: Redirecting STDOUT to a Python Variable

2012-09-23 Thread Hans Mulder
On 22/09/12 23:57:52, ross.mars...@gmail.com wrote: To capture the traceback, so to put it in a log, I use this import traceback def get_traceback(): # obtain and return the traceback exc_type, exc_value, exc_traceback = sys.exc_info() return

Re: Redirecting STDOUT to a Python Variable

2012-09-22 Thread ross . marsden
To capture the traceback, so to put it in a log, I use this import traceback def get_traceback(): # obtain and return the traceback exc_type, exc_value, exc_traceback = sys.exc_info() return ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)) Suppose I have a

Re: Redirecting STDOUT to a Python Variable

2010-06-22 Thread Paul Rubin
Anthony Papillion papill...@gmail.com writes: I'm writing an application that uses the Google Storage Python library. When an error occurs, the error is printed on the terminal. What I need to do is intercept that text into a variable so I can run a re.search() against it and find out what's

Redirecting STDOUT to a Python Variable

2010-06-22 Thread Anthony Papillion
I'm writing an application that uses the Google Storage Python library. When an error occurs, the error is printed on the terminal. What I need to do is intercept that text into a variable so I can run a re.search() against it and find out what's going on. I thought doing a output_text =

Re: Redirecting STDOUT to a Python Variable

2010-06-22 Thread James Mills
On Tue, Jun 22, 2010 at 4:10 PM, Anthony Papillion papill...@gmail.com wrote: I'm writing an application that uses the Google Storage Python library.  When an error occurs, the error is printed on the terminal. What I need to do is intercept that text into a variable so I can run a re.search()

Re: Redirecting STDOUT to a Python Variable

2010-06-22 Thread Steven D'Aprano
On Mon, 21 Jun 2010 23:10:56 -0700, Anthony Papillion wrote: I'm writing an application that uses the Google Storage Python library. When an error occurs, the error is printed on the terminal. What I need to do is intercept that text into a variable so I can run a re.search() against it and