stdout/stderr, logging, & maya's script editor

483 views
Skip to first unread message

deanareeno

unread,
Mar 12, 2014, 5:05:25 PM3/12/14
to python_in...@googlegroups.com
Hey all,

I implemented a version of the following into a module (the checkmarked answer version):


(the OutputWrapper class and handleOutput method specifcally)

...and it's working in the sense that if I call:

sys.stdout.write('Here's stdout')
sys.stdout.write('Here's stderr')

...I see each in Maya's script editor and my pyqt widget. I've also imported logging, set the logging level to INFO, and added a StreamHandler for stdout & stderr in my main module. 

What's driving me nuts is that I *only* see output in both the Script Editor and my widget if I do explicit sys.std*.write() calls in my module. Any imported functions or methods that have logging enabled passing INFO level messages or even traceback errors show up *only* in the script editor.

I tried changing the self._stream lines in the stackoverflow example to use maya.utils.Output()/ maya.utils.Output(error=1), and even sys.__stdout__/sys.__stderr__ directly, but I get the same results (with slightly different formatting).

Any ideas to point me in the right direction?

Cheers,

-DW






Justin Israel

unread,
Mar 12, 2014, 7:44:03 PM3/12/14
to python_in...@googlegroups.com

The comment on that answer seems to answer your or problem here. While you are changing the sys.stdout reference you are only doing it at a point in time. Any module that gets loaded earlier and grabs a reference will have the original.
I thought there were already some Maya utilities for interfacing with the script editor? Maya has its own references that it moves into private stdout/stderr

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f0605a26-6467-4eed-998a-dcfa8a31cfdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages