userSetup.py source all files in a folder

36 views
Skip to first unread message

BWV 656

unread,
Feb 11, 2016, 1:24:34 PM2/11/16
to Python Programming for Autodesk Maya
Hello I am trying to source all the python files in a folder via userSetup.py
 
Doing it individually works 
execfile('/u/james/myPy/Materials.py' )

However when I try to load everything it fails.

import glob
pyFiles = glob.glob("/u/james/myPy/*")

for i in pyFiles:
execfile(i)

Would you please help me how to solve this?
Thank you so much.

Justin Israel

unread,
Feb 11, 2016, 2:03:23 PM2/11/16
to Python Programming for Autodesk Maya

Are you printing the value of "i" to make sure you are getting good values?


--
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/995436aa-bdfa-4d83-9e4f-0dc20f30c02d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin Israel

unread,
Feb 11, 2016, 2:04:27 PM2/11/16
to Python Programming for Autodesk Maya

Also, please be more descriptive about the behaviour of "it fails". Is there a crash? Is it just s
not doing anything at all?

BWV 656

unread,
Feb 11, 2016, 2:53:25 PM2/11/16
to Python Programming for Autodesk Maya
Thanks Justin.
Yes when I put print i, it lists all the file.

And what i meant was it fails to load any of the py files in the folder.
Would you please tell me if there is any other way to load entire folder?

import glob
pyFiles = glob.glob("/u/james/myPy/*")

for i in pyFiles:
print i
execfile(i)

BWV 656

unread,
Feb 11, 2016, 3:01:24 PM2/11/16
to Python Programming for Autodesk Maya
I don't know what i did but now it works. All the files are sourced. must have been a typo on the path. Anyway thanks again for your help. you made me to re write the whole thing :D

Justin Israel

unread,
Feb 11, 2016, 3:35:15 PM2/11/16
to Python Programming for Autodesk Maya
I'm glad it works now, because I was going to ask again what "fails to load" meant :-) 

On Fri, Feb 12, 2016 at 9:01 AM BWV 656 <bwv...@gmail.com> wrote:
I don't know what i did but now it works. All the files are sourced. must have been a typo on the path. Anyway thanks again for your help. you made me to re write the whole thing :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_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages