protect PandaModules imports in try..except

This commit is contained in:
David Rose 2009-09-07 22:34:20 +00:00
parent f5ec249898
commit 2477befaa2
1 changed files with 5 additions and 1 deletions

View File

@ -258,7 +258,11 @@ def generateNativeWrappers():
Dtool_PreloadDLL(moduleName)
exec('import %s as module' % moduleName)
pandaModules.write('from %sModules import *\n' % (moduleName))
# Wrap the import in a try..except so that we can continue if
# the library isn't present. This is particularly necessary
# in the runtime (plugin) environment, where all libraries are
# not necessarily downloaded.
pandaModules.write('try:\n from %sModules import *\nexcept ImportError:\n pass\n\n' % (moduleName))
moduleModulesFilename = os.path.join(outputCodeDir, '%sModules.py' % (moduleName))
moduleModules = open(moduleModulesFilename, 'w')