def evaluateDataSourceExpression(self, context, propName, readablePropName): """ Return back a sane value from evaluation of an expression. @paramter context: device or component object @type context: device or component object @paramter propName: name of the threshold property to evaluate @type propName: string @paramter readablePropName: property name for displaying in error messages @type readablePropName: string @returns: numeric @rtype: numeric """ value = getattr(self, propName, None) if value: try: express = "python:%s" % value evaluated = talesEval(express, context) value = evaluated except: msg= "User-supplied Python expression (%s) for %s caused error: %s" % ( value, readablePropName, self.dsnames) log.error(msg) raise pythonThresholdException(msg) value = None return nanToNone(value)
def evaluateDataSourceExpression(self, context, propName, readablePropName): """ Return back a sane value from evaluation of an expression. @paramter context: device or component object @type context: device or component object @paramter propName: name of the threshold property to evaluate @type propName: string @paramter readablePropName: property name for displaying in error messages @type readablePropName: string @returns: numeric @rtype: numeric """ value = getattr(self, propName, None) if value: try: express = "python:%s" % value evaluated = talesEval(express, context) value = evaluated except: msg= "User-supplied Python expression (%s) for %s caused error: %s" % ( value, readablePropName, self.dsnames) log.error(msg) raise pythonThresholdException(msg) value = None return nanToNone(value)
def getPointval(self, context): """Build the point value for this threshold. """ pointval = None if self.pointval: try: pointval = talesEval("python:" + self.pointval, context) except: msg= "User-supplied Python expression (%s) for point value caused error: %s" % \ ( self.pointval, self.dsnames ) log.error(msg) raise pythonThresholdException(msg) pointval = None return pointval
def getPointval(self, context): """Build the point value for this threshold. """ pointval = None if self.pointval: try: pointval = talesEval("python:"+self.pointval, context) except: msg= "User-supplied Python expression (%s) for point value caused error: %s" % \ ( self.pointval, self.dsnames ) log.error( msg ) raise pythonThresholdException(msg) pointval = None return pointval
def getHystK(self, context): """ """ goodCount = 0 if self.goodCount: try: express = "python:%s" % self.goodCount goodCount = talesEval(express, context) except: msg = ("User-supplied Python expression (%s) for " "hysteresis K value caused error: %s") % ( self.goodCount, self.dsnames) log.error(msg) raise pythonThresholdException(msg) goodCount = 0 return goodCount
def getHystM(self, context): """ """ queueSize = 0 if self.queueSize: try: express = "python:%s" % self.queueSize queueSize = talesEval(express, context) except: msg = ("User-supplied Python expression (%s) for " "hysteresis M value caused error: %s") % ( self.queueSize, self.dsnames) log.error(msg) raise pythonThresholdException(msg) queueSize = 0 return queueSize
def getMaxval(self, context): """Build the max value for this threshold. """ maxval = None if self.maxval: try: express = "python:%s" % self.maxval maxval = talesEval(express, context) except: msg = ("User-supplied Python expression (%s) for " "maximum value caused error: %s") % (self.maxval, self.dsnames) log.error(msg) raise pythonThresholdException(msg) maxval = None return nanToNone(maxval)