warning, not error, if a module named in toon.dc doesn't exist.
This commit is contained in:
parent
5ea5135f63
commit
0d3dcf14be
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue