Browse Source

warning, not error, if a module named in toon.dc doesn't exist.

David Rose 22 years ago
parent
commit
0d3dcf14be

+ 7 - 2
direct/src/distributed/ClientDistClass.py

@@ -5,6 +5,7 @@ import DirectNotifyGlobal
 import ClientDistUpdate
 
 class ClientDistClass:
+    notify = DirectNotifyGlobal.directNotify.newCategory("ClientDistClass")
 
     def __init__(self, dcClass):
         self.number = dcClass.getNumber()
@@ -16,8 +17,12 @@ class ClientDistClass:
         self.broadcastRequiredCDU = self.listBroadcastRequiredCDU(self.allCDU)
         self.allRequiredCDU = self.listRequiredCDU(self.allCDU)
         # Import the class, and store the constructor
-        exec("import " + self.name)
-        self.constructor = eval(self.name + "." + self.name)
+        try:
+            exec("import " + self.name)
+            self.constructor = eval(self.name + "." + self.name)
+        except ImportError, e:
+            self.notify.warning("%s.py does not exist." % (self.name))
+            self.constructor = None
         return None
 
     def parseFields(self, dcClass):

+ 6 - 3
direct/src/distributed/ClientDistUpdate.py

@@ -22,13 +22,16 @@ class ClientDistUpdate:
         self.divisors = []
         self.deriveTypesFromParticle(dcField)
         # Figure out our function pointer
-        exec("import " + cdc.name, moduleGlobals, moduleLocals)
         try:
+            exec("import " + cdc.name, moduleGlobals, moduleLocals)
             self.func = eval(cdc.name + "." + cdc.name + "." + self.name)
         # Only catch name and attribute errors
         # as all other errors are legit errors
+        except ImportError, e:
+            self.notify.warning("%s.py does not exist." % (cdc.name))
+            self.func = None
         except (NameError, AttributeError), e:
-            #ClientDistUpdate.notify.warning(cdc.name + "." + self.name +
+            #self.notify.warning(cdc.name + "." + self.name +
             #                                " does not exist")
             self.func = None
         return None
@@ -47,7 +50,7 @@ class ClientDistUpdate:
                     self.types.append(componentField.getElementType(j))
                     self.divisors.append(componentField.getElementDivisor(j))
         else:
-            ClientDistUpdate.notify.error("field is neither atom nor molecule")
+            self.notify.error("field is neither atom nor molecule")
         return None
 
     def updateField(self, cdc, do, di):