Hey guys,

I'm asking the question here, maybe someone has an idea. One of our
developer is working on some pipeline tools and needs to catch exceptions
raised in Softimage.
Here is message :

*Softimage does not appear to pass errors to python's sys.stderr, even when
they are python related.*
*This is a simplified example of the Python Logger we use. It has the
useful functionality of sending*
*error report emails any time a error happens in python. Unfortunately, due
to Softimage not reporting*
*errors to sys.stderr most of these errors go unlogged. We would like to
find a way to capture these*
*errors. Yes, these errors get printed to sys.stdout, but I would like to
know if there is a way in*
*Softimage to monitor for errors without having to parse every print
statement.*

I have attached the code sample to the email. You just need to save it in
C:\temp\softimage.py and run the following code in the script editor.

import sys
sys.path.append(r'C:\temp')
import softimage
print 'Printed to the pluginlog.log'
raise Exception('This exception appears in Softimage, but is not logged
into the pluginerror.log')

Any help would be greatly appreciated ;-)

thanks,
Jeremie
# Softimage does not appear to pass errors to python's sys.stderr, even when 
they are python related.
# This is a simplified example of the Python Logger we use. It has the useful 
functionality of sending
# error report emails any time a error happens in python. Unfortunately, due to 
Softimage not reporting
# errors to sys.stderr most of these errors go unlogged. We would like to find 
a way to capture these
# errors. Yes, these errors get printed to sys.stdout, but I would like to know 
if there is a way in
# Softimage to monitor for errors without having to parse every print statement.

class Logger:
        def __init__( self, stdhandle, logfile, _print = True ):
                self._stdhandle = stdhandle
                self._logfile = logfile
                self._print = _print
                # clear the log file
                open(logfile, 'w').close()
                
        def flush( self ):
                self._stdhandle.flush()
                
        def write( self, msg ):
                f = open( self._logfile, 'a' )
                f.write( msg )
                f.close()
                if self._print:
                        self._stdhandle.write( msg )
                        
import sys, datetime, os
path = os.path.join(os.path.split(__file__)[0], r'pluginlog.log')
sys.stdout = Logger( sys.stdout, path, False )
path = os.path.join(os.path.split(__file__)[0], r'pluginerror.log')
sys.stderr = Logger( sys.stderr, path, False )
print '--------- Date: %s Version: %s ---------' % (datetime.datetime.today(), 
sys.version)


code_run_in_softimage_script_editor = """
import sys
sys.path.append(r'C:\temp')
import softimage
print 'Printed to the pluginlog.log'
raise Exception('This exception appears in Softimage, but is not logged into 
the pluginerror.log')
"""

Reply via email to