Re: [Maya-Python] Re: print to show up right of the command line

2016-07-28 Thread Aaron Carlisle
I actually figured it out. Lol :P

Since I was overwriting XStream and redefining stdout I needed to reset
stdout to point to Maya's output, but where is that? Well, the hint was
staring me in the face, I just needed to find it; the answer was in
plogging.py (pymel's logging system). There's a function called
_fixMayaOutput and they use it to reset their own logging system. I used
similar logic to flush my own system back to Maya's.

So...
import sys
from maya import utils

# redefine sys.stdout
sys.stdout = utils.Output

# in order to use stdout 'write' requires a 'maya.Output' so we flush it
class MayaOutput(sys.stdout):
def flush(*args, **kwargs):
utils.Output = MayaOutput()
sys.stdout = utils.Output

# initialize
log = MayaOutput()

# and flush, we're back to feeding output to the script editor
log.flush()

print("Hello World")

On Jul 28, 2016 9:05 PM, "yury nedelin"  wrote:

> Do you mean when you run
>
> print("something")
>
> in Python in script editor in maya, it does not print the result in the
> script editor but only in command line output?
>
> Could you explain in more detail what you are doing.
> Yury
> On Jul 28, 2016 12:33 PM,  wrote:
>
>> On Thursday, August 14, 2008 at 3:05:34 PM UTC-4, ynedelin wrote:
>> > hey is there a way to have python print into the field right of the
>> command line in Maya as it does if you print in mel?
>> >
>> > thanks
>> > Yury
>>
>> Is there a way to re-direct print output back to the script editor
>> without closing Maya?
>>
>> --
>> 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_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/b4c245a5-e2ba-41f3-86c6-20a2b41b0154%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python_inside_maya/FOJtmJjGDwc/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CACqGSch_NPQKwDbcKi%2BKAB%3DmLZxSfDuKV32aVx60fE-%2BXsXptg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAMh9y_CpatAAYzJ9h5Ajmnih%2BjS1qdjfE8Hgkfbt2LRyaKrCxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: print to show up right of the command line

2016-07-28 Thread yury nedelin
Do you mean when you run

print("something")

in Python in script editor in maya, it does not print the result in the
script editor but only in command line output?

Could you explain in more detail what you are doing.
Yury
On Jul 28, 2016 12:33 PM,  wrote:

> On Thursday, August 14, 2008 at 3:05:34 PM UTC-4, ynedelin wrote:
> > hey is there a way to have python print into the field right of the
> command line in Maya as it does if you print in mel?
> >
> > thanks
> > Yury
>
> Is there a way to re-direct print output back to the script editor without
> closing Maya?
>
> --
> 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_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/b4c245a5-e2ba-41f3-86c6-20a2b41b0154%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CACqGSch_NPQKwDbcKi%2BKAB%3DmLZxSfDuKV32aVx60fE-%2BXsXptg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: Re-Direct print back to the Script Editor

2016-07-28 Thread Aaron Carlisle
So that actually got me looking in the right area! Thanks Robert.

Here's the solution:

Since I was overwriting XStream and redefining stdout I needed to reset
stdout to point to Maya's output, but where is that? Well, the hint was
staring me in the face, I just needed to find it; the answer was in
plogging.py (pymel's logging system. There's a function called
_fixMayaOutput and they use it to reset their own logging system.

So...
import sys
from maya import utils

# redefine sys.stdout
sys.stdout = utils.Output

# in order to use stdout 'write' requires a 'maya.Output' so we flush it
class MayaOutput(sys.stdout):
def flush(*args, **kwargs):
utils.Output = MayaOutput()
sys.stdout = utils.Output

# initialize
log = MayaOutput()

# and flush, we're back to feeding output to the script editor
log.flush()

print("Hello World")

Thanks for your help Robert!

On Thu, Jul 28, 2016 at 12:18 PM, Robert White 
wrote:

> If you're on windows the following file is where the maya log handling
> stuff gets setup. Should be in a fairly similar place on other OSs
>
> C:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages\maya\utils.py
>
> That should hopefully give you a starting point for how they're hooking
> into stdout/stderr and getting it to the script editor.
> I honestly can't remember what I had done to get it logging to both a file
> and not interrupting the internal handler.
>
> On Thursday, July 28, 2016 at 10:38:10 AM UTC-5, Aaron Carlisle wrote:
>>
>> I wrote a logging system that redefines XStream and directs stdout and
>> stderr to a Qt window so that I can also log output to a file (selectively).
>>
>> This broke the Python print statement and the output of that will no
>> longer show up in Maya's script editor.
>>
>> Is there a way to reset Maya's internal Python printing? They're
>> obviously doing something in the API because it include line endings and
>> coloring output, I'm just not sure how to re-initialize it.
>>
>> Any input would helpful!!
>>
>> Thanks!
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python_inside_maya/YdDjCgVM6Jw/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/25ac4db1-4fb4-4a73-87e7-9501ccd834b6%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CADwEHsM3Lxd_DDgcigP_sHeDFThzE-2trykfkFGa4Hvvn992ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: print to show up right of the command line

2016-07-28 Thread aaron . carlisle
On Thursday, August 14, 2008 at 3:05:34 PM UTC-4, ynedelin wrote:
> hey is there a way to have python print into the field right of the command 
> line in Maya as it does if you print in mel?
> 
> thanks 
> Yury

Is there a way to re-direct print output back to the script editor without 
closing Maya?

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/b4c245a5-e2ba-41f3-86c6-20a2b41b0154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Re-Direct print back to the Script Editor

2016-07-28 Thread Robert White
If you're on windows the following file is where the maya log handling 
stuff gets setup. Should be in a fairly similar place on other OSs

C:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages\maya\utils.py

That should hopefully give you a starting point for how they're hooking 
into stdout/stderr and getting it to the script editor.
I honestly can't remember what I had done to get it logging to both a file 
and not interrupting the internal handler.

On Thursday, July 28, 2016 at 10:38:10 AM UTC-5, Aaron Carlisle wrote:
>
> I wrote a logging system that redefines XStream and directs stdout and 
> stderr to a Qt window so that I can also log output to a file (selectively).
>
> This broke the Python print statement and the output of that will no 
> longer show up in Maya's script editor.
>
> Is there a way to reset Maya's internal Python printing? They're obviously 
> doing something in the API because it include line endings and coloring 
> output, I'm just not sure how to re-initialize it.
>
> Any input would helpful!!
>
> Thanks!
>

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/25ac4db1-4fb4-4a73-87e7-9501ccd834b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re-Direct print back to the Script Editor

2016-07-28 Thread Aaron Carlisle
I wrote a logging system that redefines XStream and directs stdout and 
stderr to a Qt window so that I can also log output to a file (selectively).

This broke the Python print statement and the output of that will no longer 
show up in Maya's script editor.

Is there a way to reset Maya's internal Python printing? They're obviously 
doing something in the API because it include line endings and coloring 
output, I'm just not sure how to re-initialize it.

Any input would helpful!!

Thanks!

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/9d416c22-4b0e-4b68-878a-69527137c0a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.