Getting license serial number

81 views
Skip to first unread message

Kenneth Ibrahim

unread,
May 4, 2015, 12:12:42 PM5/4/15
to python_in...@googlegroups.com
Simple question and hopefully 1 liner script answer :)

How does one poll the serial number of the currently running Maya session?

I tried the command 'license' but need to extract the serial number from the return unicode string given the 'info' option. That's fine though it seems that they would provide selectors for specific information.

I can go with this but it seems that all of the options to this command have been deprecated in Maya 2016 so I'll need different approaches with different versions.

Thx! Ken

--
"God is a metaphor for a mystery that absolutely transcends all human categories of thought. It's as simple as that!" - Joseph Campbell

Mahmoodreza Aarabi

unread,
May 4, 2015, 2:16:14 PM5/4/15
to python_in...@googlegroups.com
hey
```python
from maya import cmds
cmds.license(showProductInfoDialog=True)
```
just this command works in maya 2016

--
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/CAP_aC5Z4rhUynyCxbtaP_uMtrtgpmGTpJMdyyLjS-FDt9k85iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Mahmoodreza Aarabi

unread,
May 4, 2015, 2:16:36 PM5/4/15
to python_in...@googlegroups.com

hey

from maya import cmds
cmds.license(showProductInfoDialog=True)

just this command works in maya 2016

On Mon, May 4, 2015 at 8:42 PM, Kenneth Ibrahim <kenib...@gmail.com> wrote:

--
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/CAP_aC5Z4rhUynyCxbtaP_uMtrtgpmGTpJMdyyLjS-FDt9k85iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Kenneth Ibrahim

unread,
May 4, 2015, 3:07:21 PM5/4/15
to python_in...@googlegroups.com
Thx for the info here. That actually caused Maya to hang (on Mac) for some reason.

Anyway, I'm trying to get the serial number programmatically without opening any dialog windows.


For more options, visit https://groups.google.com/d/optout.



--

Mahmoodreza Aarabi

unread,
May 4, 2015, 3:46:18 PM5/4/15
to python_in...@googlegroups.com

did you used flages of
cmds.about() ?



For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Kenneth Ibrahim

unread,
May 4, 2015, 3:58:07 PM5/4/15
to python_in...@googlegroups.com
Yes, as far as I could tell there is no access to license info.


For more options, visit https://groups.google.com/d/optout.

Anthony Tan

unread,
May 5, 2015, 1:57:10 AM5/5/15
to python_in...@googlegroups.com
I know, it's just parsing text, but isn't text slice pretty much a one-liner anyway?
 
import re
import maya.cmds as mc
 
print re.search('serialnumber\t*(?P<serialnumber>[0-9-]*)\n',mc.license(info=True)).group('serialnumber')
 
It's not as clean as say, mc.license(serial=True), and I wouldn't write it out like that because it's awful to read, but it doesn't strike me as a particularly hairy task. You could even just patch in startup code in user.py to add the parse of the serial number etc into the os.environ dictionary so you could treat it like a system variable?

Mahmoodreza Aarabi

unread,
May 5, 2015, 2:06:09 AM5/5/15
to python_in...@googlegroups.com

But Anthony, this line does not work on maya 2016 : cmds.license(info=True)
info flag is obsolete in 2016



For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Anthony Tan

unread,
May 5, 2015, 2:19:55 AM5/5/15
to python_in...@googlegroups.com
May have been my misread, but thought the question as a general Maya one, with an exception needed for 2016.
 
2016 is a hard one to make a general case for because the entire lisc model is getting a bit of a shake-up so it depends on what is trying to be done (do products under subscription even have a serial number??) as to what kind of approach you'd do there. 

Mahmoodreza Aarabi

unread,
May 5, 2015, 2:27:56 AM5/5/15
to python_in...@googlegroups.com
maybe we can get serial number from the "Product License Information" window.
do you have any experience in this way? getting information of a window.
or at least if we can save information of this window to a text file we can easily access to information (like save as button)


For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Anthony Tan

unread,
May 5, 2015, 9:33:21 AM5/5/15
to python_in...@googlegroups.com
If it's a QT window, sure, with a little probing you could probably track down the UI element and read out the string, but I don't really think it's worth the effort to do it and it's an awfully brittle process. There's a save as button which will dump the data to a text file, but again, unless there's a good reason to automate this *exact* specific process, I'd find another way. An example: if in 2016 they're still going to run licences via Flex, then surely it'd be easier querying the license server? (noting i have zero info about 2016, it's just not something on my radar right now) 

Kenneth Ibrahim

unread,
May 5, 2015, 12:28:31 PM5/5/15
to python_in...@googlegroups.com
Gentlemen, thanks for the ideas here. By a one-liner I meant if anyone knew of a different API call that would return the serial number alone (or have flags to do that). Parsing the info returned in 2015 isn't an issue but it's always better if the developer provides targeted API routines. And I was thinking that perhaps I missed some new callback that would work for both 2015 & 2016.


For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages