project paths

18 views
Skip to first unread message

Todd Widup

unread,
May 2, 2017, 4:39:25 PM5/2/17
to python_in...@googlegroups.com
got an interesting issue at work.

we use perforce for source control on all art assets.  and do to a lack in guidance, almost everyone on the art team has their perforce installs done in different locations and paths

ie :
D:/p4, E:/PROJECTS, C:/p4, et al

Anyone have suggestions on how to setup the project paths so that it would strip out the drive and root and just use the perforce directories as teh root for the project?  ...in our case, Interactive

thanks
-todd

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

Michael Boon

unread,
May 2, 2017, 11:35:29 PM5/2/17
to Python Programming for Autodesk Maya
If you run "p4 info" in a subprocess, you can then look up "Client root". Something like this:
info = subprocess.check_output('p4 info')
info = info.splitlines()
info = [L.split(':', 1) for L in info]
info = dict(info)
p4Root = info['Client root']

You can then compare p4Root to the paths you're interested in, something like:
p4Root = os.path.normcase(os.path.normpath(p4Root))
path = os.path.normcase(os.path.normpath(path))
if not path.startswith(p4Root):
raise WhateverError()

Todd Widup

unread,
May 3, 2017, 12:21:49 AM5/3/17
to python_in...@googlegroups.com
ill giv it a try in the morning :D

--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/89e8d241-1e5e-4c2d-bc46-83f85d68df6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages