Loading egg from URLs

Just a small snippet. Someone was looking for a way to load egg files from URLs. I though I’d post it here since someone else may be wondering about that.

# Import the retriever function 
from urllib import urlretrieve

# Get the file in a temp file 
urlretrieve(myURL, 'models/temp.egg')

# Do whatever you want with the file (Panda3D specific)
foo = loader.loadModel("models/temp.egg")

A more complete solution would probably name the resource with a better name and check the local folder before calling urlretrieve, or systematically clean up the dowloaded file before closing.

It’s a python thing, not a Panda3D function:

the problem doing it that way is that it stops panda3d main loop while the model is downloading. A better approach is to use panda3d’s HTTPClient() and channels.