瀏覽代碼

protect against ImportError

David Rose 16 年之前
父節點
當前提交
274cbb24e4
共有 1 個文件被更改,包括 9 次插入3 次删除
  1. 9 3
      direct/src/showutil/FreezeTool.py

+ 9 - 3
direct/src/showutil/FreezeTool.py

@@ -612,8 +612,11 @@ class Freezer:
             path = self.getModulePath(parentName)
             if path == None:
                 return None
-            
-        file, pathname, description = imp.find_module(baseName, path)
+
+        try:
+            file, pathname, description = imp.find_module(baseName, path)
+        except ImportError:
+            return None
 
         if not os.path.isdir(pathname):
             return None
@@ -826,7 +829,10 @@ class Freezer:
 
         else:
             # Otherwise, we can just import it normally.
-            self.mf.import_hook(mdef.moduleName)
+            try:
+                self.mf.import_hook(mdef.moduleName)
+            except ImportError:
+                print "Unknown module: %s" % (mdef.moduleName)
 
     def reset(self):
         """ After a previous call to done(), this resets the