Re: [Maya-Python] custom logger handler

2017-09-28 Thread Sebastian Schoellhammer
The problem is that it never actually get to the emit function, it makes no
difference if I comment the stuff about the widget..

On Wed, Sep 27, 2017 at 8:38 PM, Justin Israel 
wrote:

>
>
> On Thu, Sep 28, 2017, 12:45 AM Sebastian Schoellhammer <
> sschoellhammer.li...@gmail.com> wrote:
>
>> Hi!
>>
>> Has anybody tried to create a custom logger handler?
>>
>> I wanted to make on that outputs to a qt widget but I can't even get my
>> emit function to be called :/
>>
>> Here's my code:
>> https://pastebin.com/TV7Cf0fw
>>
>> If anybody sees something obvious, please let me know!
>>
>
> Your example never sets the widget for the log handler. Additionally you
> never default self.loggingWidget=None in your __init__() so I would
> expect your handler to crash when it goes to emit and hits an undefined
> field.
>
>
>> Thanks!!
>>
>> seb
>>
>> --
>> 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/CAMLepcZUUWmA%2B_wMb5TEgvPCJis%2BkCn%
>> 2BhfWTP2cZ78ou9CVb_w%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/CAPGFgA2CY787GOLAH-ewu1LbJm%
> 3DcQwDjDmcsYxEP4rtBeWYdYw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Sebastian Schoellhammer

w ww.mokumedia.de 

-- 
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/CAMLepcar3eex%2B8oKtXtHxg9jhp%2BqTSXh00cyL7KdnJ%3Ds0xk4LQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] custom logger handler

2017-09-28 Thread Justin Israel
On Thu, Sep 28, 2017 at 9:13 PM Sebastian Schoellhammer <
sschoellhammer.li...@gmail.com> wrote:

> The problem is that it never actually get to the emit function, it makes
> no difference if I comment the stuff about the widget..
>

It's because you are adding your handler to your custom logger instance but
then logging to the main root logger. If you do either of the following,
you will encounter the crash in your logger:

logger.info("bla")
logger.debug("bla2")

​
or

logging.getLogger().addHandler(QtLoggingHandler())

​

Justin



>
> On Wed, Sep 27, 2017 at 8:38 PM, Justin Israel 
> wrote:
>
>>
>>
>> On Thu, Sep 28, 2017, 12:45 AM Sebastian Schoellhammer <
>> sschoellhammer.li...@gmail.com> wrote:
>>
>>> Hi!
>>>
>>> Has anybody tried to create a custom logger handler?
>>>
>>> I wanted to make on that outputs to a qt widget but I can't even get my
>>> emit function to be called :/
>>>
>>> Here's my code:
>>> https://pastebin.com/TV7Cf0fw
>>>
>>> If anybody sees something obvious, please let me know!
>>>
>>
>> Your example never sets the widget for the log handler. Additionally you
>> never default self.loggingWidget=None in your __init__() so I would expect
>> your handler to crash when it goes to emit and hits an undefined field.
>>
>>
>>> Thanks!!
>>>
>>> seb
>>>
>>> --
>>> 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/CAMLepcZUUWmA%2B_wMb5TEgvPCJis%2BkCn%2BhfWTP2cZ78ou9CVb_w%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/CAPGFgA2CY787GOLAH-ewu1LbJm%3DcQwDjDmcsYxEP4rtBeWYdYw%40mail.gmail.com
>> 
>> .
>
>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Sebastian Schoellhammer
>
> w ww.mokumedia.de 
>
> --
> 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/CAMLepcar3eex%2B8oKtXtHxg9jhp%2BqTSXh00cyL7KdnJ%3Ds0xk4LQ%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/CAPGFgA1pF0dzwm20Rp6WBGs0Lm8HGrYui9e_ovXsH%3DJoNiO%2B6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] P4python doesn't work under maya 2017

2017-09-28 Thread 'riga_rig' via Python Programming for Autodesk Maya
Hi,
I tried to access our perforce server from Maya 2017.
from P4 import P4,P4Exception# Import the module
p4 = P4()# Create the P4 instance
#p4.host = "ssl:perforce:1666"
p4.port = "ssl:perforce:1666"
p4.user = "user_name"
p4.password = "secret"
p4.client = "my_workspace"# Set some environment variables
p4.connect()

It works good from  external python console, but in Script Editor I got 
following error:
# Error: line 1: [P4.connect()] Connect to server failed; check $P4PORT.
# SSL library must be at least version 1.0.1.
# Traceback (most recent call last):
#   File "", line 8, in 
#   File "C:\Program 
Files\Autodesk\Maya2017\Python\lib\site-packages\P4.py", line 798, in 
connect
# P4API.P4Adapter.connect( self )
# P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
# SSL library must be at least version 1.0.1. # 

I'm under Windows 10. P4Python was installed 
from p4python-2017.1.1526044-cp27-cp27m-win_amd64.whl.

Python version in Maya 2017:
import sys
sys.version
# Result: 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit 
(AMD64)]

Do you have any ideas how to fix it?
Is anybody uses Perforce P4Python lib from Maya?
Regards,
Oleg Solovjov

-- 
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/4eeb25ac-123e-4499-afe9-d4ca5ecc9547%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: P4python doesn't work under maya 2017

2017-09-28 Thread Robert White
Last job I was using the version that I've shared here 
,
 
I had tested it up through 2017, but it might work in 2018 as well (no 
promises on 2018).
It was compiled with OpenSSL-1.0.2c, so that should potentially help with 
your SSL version error.

On Thursday, September 28, 2017 at 7:20:55 AM UTC-5, riga_rig wrote:
>
> Hi,
> I tried to access our perforce server from Maya 2017.
> from P4 import P4,P4Exception# Import the module
> p4 = P4()# Create the P4 instance
> #p4.host = "ssl:perforce:1666"
> p4.port = "ssl:perforce:1666"
> p4.user = "user_name"
> p4.password = "secret"
> p4.client = "my_workspace"# Set some environment variables
> p4.connect()
>
> It works good from  external python console, but in Script Editor I got 
> following error:
> # Error: line 1: [P4.connect()] Connect to server failed; check $P4PORT.
> # SSL library must be at least version 1.0.1.
> # Traceback (most recent call last):
> #   File "", line 8, in 
> #   File "C:\Program 
> Files\Autodesk\Maya2017\Python\lib\site-packages\P4.py", line 798, in 
> connect
> # P4API.P4Adapter.connect( self )
> # P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
> # SSL library must be at least version 1.0.1. # 
>
> I'm under Windows 10. P4Python was installed 
> from p4python-2017.1.1526044-cp27-cp27m-win_amd64.whl.
>
> Python version in Maya 2017:
> import sys
> sys.version
> # Result: 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit 
> (AMD64)]
>
> Do you have any ideas how to fix it?
> Is anybody uses Perforce P4Python lib from Maya?
> Regards,
> Oleg Solovjov
>
>

-- 
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/829fec84-43fd-4418-859e-d5611437b49e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] word sorting script not giving me the results I am expecting.

2017-09-28 Thread jettam
Thank you again.  :) 

On Wednesday, September 27, 2017 at 11:34:30 AM UTC-7, Justin Israel wrote:
>
>
>
> On Thu, Sep 28, 2017, 6:05 AM jettam > 
> wrote:
>
>> This is great, thanks.   
>>
>> *I see in this section you are building the dictionary, assigning both 
>> keys and values, but I have some questions, see **red*
>> for word in line.upper().split():   *# I get this, you split the 
>> words into a list*
>> try:
>> occurences[word] += 1  *# Looks like you are giving the 
>> dict keys. But I am not sure how you are also inserting values. * 
>>
>
> This is standard syntax for using a dictionary. You assign a value to a 
> key. In this particular line, I am using the  x += 1 expression to add 1 to 
> the current key value in the dictionary. It is the equivalent of doing 
>
> occurrences[word] = occurrences[word] + 1
>
>
>> except KeyError:  *# Not sure what this is doing!  *
>> occurences[word] = 1  *# or this*
>>
>
> If you try to access a key in a dictionary that does not exist, Python 
> will raise a KeyError exception. So first I am trying to increment an 
> existing key (making the assumption that we had already added the word 
> before). If we have never added that word yet, we catch the error and just 
> start the new value at 1. This is how you count up each time you see the 
> same word. 
>
> I could have avoided the exception by writing this a different way, where 
> we actually check if the key exists first 
>
> if word in occurrences[word]:
> occurrences[word] += 1
> else:
> occurrences[word] = 1
>
> It has the same effect but included needing to look up the key once first 
> to see if it exist. The previous way I had done it is using the "easier to 
> ask forgiveness than permission" approach. 
>
>
>>
>> *Looks like you are sorting the occurrences dict into a descending order 
>> based on the values?   So h**ow are you telling sorted to look at the 
>> values fields to sort ? *
>> ordered = sorted(occurences, key=occurences.get, reverse=True)
>>
>
> sort functions by default will just use each item for the comparisons when 
> sorting. We don't want it to sort by the keys. So sorted() accepts a key 
> function that it will call for each item to give it the sort key to use for 
> comparisons. Since a dictionary has a handy  dict.get(key) method for 
> getting a value for a key, we can just have it use that. Now it will sort 
> the keys by getting each value for comparison. 
>
> https://wiki.python.org/moin/HowTo/Sorting#Key_Functions
>
>
>>
>>
>>
>> On Tuesday, September 26, 2017 at 7:56:16 PM UTC-7, Justin Israel wrote:
>>
>>>
>>>
>>> On Wed, Sep 27, 2017 at 1:02 PM jettam  wrote:
>>>
 Thanks for your help Justin.  I would like an example.

>>>
>>> Here is an example of the changes I had suggested:
>>> https://repl.it/Lfva/1
>>>
>>> occurences = {}
>>> punct = set(["'", "?", ".", "!", ",", "\r\n", "-"])
>>> with open(inFile, 'r') as fin
>>> for line in fin:
>>> for p in punct:
>>> line = line.replace(p,"")
>>>
>>> for word in line.upper().split():
>>> try:
>>> occurences[word] += 1
>>> except KeyError:
>>> occurences[word] = 1
>>>
>>> ordered = sorted(occurences, key=occurences.get, reverse=True)
>>> topThree = ordered[:3]
>>> for k in topThree:
>>> v = occurences[k]
>>> print 'the word " %s " occured %s times' % (k,v)
>>>
>>> ​
>>>  
>>>

 *"It would be better to just build up a dictionary directly within that 
> word loop. That way you have a unique mapping of words to their 
> occurrences. Then you can use sorted(words.items(), words.get) in order 
> to 
> sort the words by their value, in reverse order. That resulting list will 
> let you slice off the last three, which will be the (key, val) tuples. 
> You 
> will no longer have issues with managing separate key/value lists. Let me 
> know if you want the example"*



 Regarding the zipping of two lists to make a dictionary. I haven't 
 noticed any disassociate of key and values in the process. The length of 
 the list did shrink but only because the zipping process removes 
 duplicates. So instead of seeing the word AND appear 24 times, in the 
 zipped dictionary it appeared only once like this {'AND':24}

>>>
>>> The zipping process doesn't remove duplicates. Converting your list to a 
>>> set is what removes duplicates. Both calling sorted() and converting to a 
>>> set() changes the order of your values so that they no longer map to the 
>>> original keys. So you end up with this order of random values. Then you can 
>>> no longer map them back to the exact words since you can have duplicate 
>>> word count values. 
>>>  
>>>





 -- 
 You received this message because you are subscribed to the Google 
 Groups "Python Programming for Autodesk Maya" grou

Re: [Maya-Python] Re: P4python doesn't work under maya 2017

2017-09-28 Thread Todd Widup
hey Robert..is there any documentation on your compile?  like what syntax
its looking for and such, or do I have to do run("p4 command","files")


On Thu, Sep 28, 2017 at 5:46 AM, Robert White 
wrote:

> Last job I was using the version that I've shared here
> ,
> I had tested it up through 2017, but it might work in 2018 as well (no
> promises on 2018).
> It was compiled with OpenSSL-1.0.2c, so that should potentially help with
> your SSL version error.
>
> On Thursday, September 28, 2017 at 7:20:55 AM UTC-5, riga_rig wrote:
>>
>> Hi,
>> I tried to access our perforce server from Maya 2017.
>> from P4 import P4,P4Exception# Import the module
>> p4 = P4()# Create the P4 instance
>> #p4.host = "ssl:perforce:1666"
>> p4.port = "ssl:perforce:1666"
>> p4.user = "user_name"
>> p4.password = "secret"
>> p4.client = "my_workspace"# Set some environment variables
>> p4.connect()
>>
>> It works good from  external python console, but in Script Editor I got
>> following error:
>> # Error: line 1: [P4.connect()] Connect to server failed; check $P4PORT.
>> # SSL library must be at least version 1.0.1.
>> # Traceback (most recent call last):
>> #   File "", line 8, in 
>> #   File "C:\Program Files\Autodesk\Maya2017\Python\lib\site-packages\P4.py",
>> line 798, in connect
>> # P4API.P4Adapter.connect( self )
>> # P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
>> # SSL library must be at least version 1.0.1. #
>>
>> I'm under Windows 10. P4Python was installed
>> from p4python-2017.1.1526044-cp27-cp27m-win_amd64.whl.
>>
>> Python version in Maya 2017:
>> import sys
>> sys.version
>> # Result: 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit
>> (AMD64)]
>>
>> Do you have any ideas how to fix it?
>> Is anybody uses Perforce P4Python lib from Maya?
>> Regards,
>> Oleg Solovjov
>>
>> --
> 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/829fec84-43fd-4418-859e-
> d5611437b49e%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Todd Widup
Creature TD / Technical Artist
todd.wi...@gmail.com

-- 
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/CABBPk365nNJu1d1%2BgvbrbFVDYxjS79VU4iE%3D0j13iO9MDRTijw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: P4python doesn't work under maya 2017

2017-09-28 Thread Robert White
It should behave the same as any other version of P4Python. All I did was 
include the OpenSSL value, and compile it with a maya compatible compiler 
version.

On Thursday, September 28, 2017 at 11:07:22 AM UTC-5, todd@gmail.com 
wrote:
>
> hey Robert..is there any documentation on your compile?  like what syntax 
> its looking for and such, or do I have to do run("p4 command","files")
>
>
> On Thu, Sep 28, 2017 at 5:46 AM, Robert White  > wrote:
>
>> Last job I was using the version that I've shared here 
>> ,
>>  
>> I had tested it up through 2017, but it might work in 2018 as well (no 
>> promises on 2018).
>> It was compiled with OpenSSL-1.0.2c, so that should potentially help with 
>> your SSL version error.
>>
>> On Thursday, September 28, 2017 at 7:20:55 AM UTC-5, riga_rig wrote:
>>>
>>> Hi,
>>> I tried to access our perforce server from Maya 2017.
>>> from P4 import P4,P4Exception# Import the module
>>> p4 = P4()# Create the P4 instance
>>> #p4.host = "ssl:perforce:1666"
>>> p4.port = "ssl:perforce:1666"
>>> p4.user = "user_name"
>>> p4.password = "secret"
>>> p4.client = "my_workspace"# Set some environment variables
>>> p4.connect()
>>>
>>> It works good from  external python console, but in Script Editor I got 
>>> following error:
>>> # Error: line 1: [P4.connect()] Connect to server failed; check $P4PORT.
>>> # SSL library must be at least version 1.0.1.
>>> # Traceback (most recent call last):
>>> #   File "", line 8, in 
>>> #   File "C:\Program 
>>> Files\Autodesk\Maya2017\Python\lib\site-packages\P4.py", line 798, in 
>>> connect
>>> # P4API.P4Adapter.connect( self )
>>> # P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
>>> # SSL library must be at least version 1.0.1. # 
>>>
>>> I'm under Windows 10. P4Python was installed 
>>> from p4python-2017.1.1526044-cp27-cp27m-win_amd64.whl.
>>>
>>> Python version in Maya 2017:
>>> import sys
>>> sys.version
>>> # Result: 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit 
>>> (AMD64)]
>>>
>>> Do you have any ideas how to fix it?
>>> Is anybody uses Perforce P4Python lib from Maya?
>>> Regards,
>>> Oleg Solovjov
>>>
>>> -- 
>> 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/829fec84-43fd-4418-859e-d5611437b49e%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Todd Widup
> Creature TD / Technical Artist
> todd@gmail.com 
>

-- 
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/9d26e1e7-30de-4bb8-bf64-48ec85515ccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: Widgets not updating when docked using workspaceControl PySide2/Maya2017

2017-09-28 Thread cgarcia
Hi,

I got the same error, but I found a way to get it to work...

What I do is before I create the widget that is going into the Workspace I 
create a dummy one. I'm guessing that the bug is due to some initialization 
that is not been done on the first Workspace created, here is the dummy 
dialog...
main_window_ptr = omui.MQtUtil.mainWindow()
mayaWid = QtCompat.wrapInstance(long(main_window_ptr), 
QtWidgets.QWidget)

class dummyClass(MayaQWidgetDockableMixin, QtWidgets.QDialog):
def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent)

_dummyUI = dummyClass(mayaWid)

_dummyUI.setObjectName("DockingDummyWindow")
workspaceControlName = _dummyUI.objectName() + 'WorkspaceControl'

_dummyUI.show(dockable=True, area='right', floating=False)
cmds.workspaceControl(workspaceControlName, e=True, 
  ttc=["AttributeEditor", -1], wp="preferred",
  mw=420)

cmds.workspaceControl(workspaceControlName, e=True, close=True)
cmds.deleteUI(workspaceControlName, control=True)

Once this is deleted, you add the code that creates the real UI.

It works for me, so maybe try it out.

Cheers,

-- 
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/a0c45475-217e-46a0-94c2-29c1fa0b257a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.