def build(self):
		"""Build an OscBundle with the current state of this builder.

		Raises:
			- BuildError: if we could not build the bundle.
		"""
		dgram = b'#bundle\x00'
		try:
			dgram += osc_types.write_date(self._timestamp)
			for content in self._contents:
				if (type(content) == osc_message.OscMessage
						or type(content) == osc_bundle.OscBundle):
					size = content.size
					dgram += osc_types.write_int(size)
					dgram += content.dgram
				else:
					raise BuildError(
							"Content must be either OscBundle or OscMessage"
							"found {}".format(type(content)))
			return osc_bundle.OscBundle(dgram)
		except osc_types.BuildError as be:
			raise BuildError('Could not build the bundle {}'.format(be))
  def build(self):
    """Build an OscBundle with the current state of this builder.

    Raises:
      - BuildError: if we could not build the bundle.
    """
    dgram = b'#bundle\x00'
    try:
      dgram += osc_types.write_date(self._timestamp)
      for content in self._contents:
        if (type(content) == osc_message.OscMessage
            or type(content) == osc_bundle.OscBundle):
          size = content.size
          dgram += osc_types.write_int(size)
          dgram += content.dgram
        else:
          raise BuildError(
              "Content must be either OscBundle or OscMessage"
              "found {}".format(type(content)))
      return osc_bundle.OscBundle(dgram)
    except osc_types.BuildError as be:
      raise BuildError('Could not build the bundle {}'.format(be))
Example #3
0
 def test_write_date(self):
     self.assertEqual(b'\x83\xaa~\x83\x00\x00\x059',
                      osc_types.write_date(3.1337))
Example #4
0
 def test_write_date(self):
   self.assertEqual(b'\x83\xaa~\x83\":)\xc7', osc_types.write_date(3.1337))
Example #5
0
 def test_write_date(self):
     time = 1569899476.167749  # known round(time.time(), 6)
     timetag = b'\xe1=BT*\xf1\x98\x00'
     self.assertEqual(timetag, osc_types.write_date(time))