示例#1
0
	def valtobuf(self, val, bufp):
		if self._type == libweb100.WEB100_TYPE_INTEGER or \
		   self._type == libweb100.WEB100_TYPE_INTEGER32:
			libweb100.s32p_assign(libweb100.bufp_to_s32p(bufp), val)
			return bufp
		elif self._type == libweb100.WEB100_TYPE_GAUGE32 or \
		     self._type == libweb100.WEB100_TYPE_UNSIGNED32:
			libweb100.u32p_assign(libweb100.bufp_to_u32p(bufp), val)
			return bufp
		elif self._type == libweb100.WEB100_TYPE_STR32:
			return libweb100.str_to_bufp(val)
		else:
			raise error("Unknown or unwritable type: %d"%self._type)
示例#2
0
 def valtobuf(self, val, bufp):
     if self._type == libweb100.WEB100_TYPE_INTEGER or \
        self._type == libweb100.WEB100_TYPE_INTEGER32:
         libweb100.s32p_assign(libweb100.bufp_to_s32p(bufp), val)
         return bufp
     elif self._type == libweb100.WEB100_TYPE_GAUGE32 or \
          self._type == libweb100.WEB100_TYPE_UNSIGNED32:
         libweb100.u32p_assign(libweb100.bufp_to_u32p(bufp), val)
         return bufp
     elif self._type == libweb100.WEB100_TYPE_STR32:
         return libweb100.str_to_bufp(val)
     else:
         raise error("Unknown or unwritable type: %d" % self._type)
示例#3
0
	def val(self, bufp):
		if self._type == libweb100.WEB100_TYPE_INET_PORT_NUMBER or\
		   self._type == libweb100.WEB100_TYPE_UNSIGNED16:
			return libweb100.u16p_value(libweb100.bufp_to_u16p(bufp))
		elif self._type == libweb100.WEB100_TYPE_INTEGER or \
		     self._type == libweb100.WEB100_TYPE_INTEGER32:
			return libweb100.s32p_value(libweb100.bufp_to_s32p(bufp))
		elif self._type == libweb100.WEB100_TYPE_COUNTER32 or \
		     self._type == libweb100.WEB100_TYPE_GAUGE32 or \
		     self._type == libweb100.WEB100_TYPE_UNSIGNED32 or \
		     self._type == libweb100.WEB100_TYPE_TIME_TICKS:
			return libweb100.u32p_value(libweb100.bufp_to_u32p(bufp))
		elif self._type == libweb100.WEB100_TYPE_COUNTER64:
			return libweb100.u64p_value(libweb100.bufp_to_u64p(bufp))
		else:
			return libweb100.web100_value_to_text(self._type, bufp)
示例#4
0
 def val(self, bufp):
     if self._type == libweb100.WEB100_TYPE_INET_PORT_NUMBER or\
        self._type == libweb100.WEB100_TYPE_UNSIGNED16:
         return libweb100.u16p_value(libweb100.bufp_to_u16p(bufp))
     elif self._type == libweb100.WEB100_TYPE_INTEGER or \
          self._type == libweb100.WEB100_TYPE_INTEGER32:
         return libweb100.s32p_value(libweb100.bufp_to_s32p(bufp))
     elif self._type == libweb100.WEB100_TYPE_COUNTER32 or \
          self._type == libweb100.WEB100_TYPE_GAUGE32 or \
          self._type == libweb100.WEB100_TYPE_UNSIGNED32 or \
          self._type == libweb100.WEB100_TYPE_TIME_TICKS:
         return libweb100.u32p_value(libweb100.bufp_to_u32p(bufp))
     elif self._type == libweb100.WEB100_TYPE_COUNTER64:
         return libweb100.u64p_value(libweb100.bufp_to_u64p(bufp))
     else:
         return libweb100.web100_value_to_text(self._type, bufp)