Exemplo n.º 1
0
 def testCreateFromValue(self):
     self.assertEquals(type(osc.createArgument(True)), osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(False)), osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(None)), osc.NullArgument)
     self.assertEquals(type(osc.createArgument(123)), osc.IntArgument)
     self.assertEquals(type(osc.createArgument(3.14156)), osc.FloatArgument)
     # Unicode is not supported.
     self.assertRaises(osc.OscError, osc.createArgument, u'test')
Exemplo n.º 2
0
 def testCreateFromValue(self):
     self.assertEquals(type(osc.createArgument(True)), osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(False)), osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(None)), osc.NullArgument)
     self.assertEquals(type(osc.createArgument(123)), osc.IntArgument)
     self.assertEquals(type(osc.createArgument(3.14156)), osc.FloatArgument)
     # Unicode is not supported.
     self.assertRaises(osc.OscError, osc.createArgument, u'test')
Exemplo n.º 3
0
def create_message_manually(path, types, *args):
    """
    The used specified the type tags.
    """
    def _exit_with_error(message):
        global RETURN_VALUE
        if reactor.running:
            reactor.stop()
        print(message)
        RETURN_VALUE = 1  # error

    if len(types) != len(args):
        _exit_with_error(
            "The length of the type string must match the number of arguments."
        )
        return

    message = osc.Message(path)
    try:
        for value, typetag in zip(args, types):
            verb("Creating argument for %s with type tag %s" %
                 (value, typetag))
            cast = str

            if typetag == "i":
                cast = int
            elif typetag == "f":
                cast = float
            elif typetag in ["T", "F"]:
                cast = None
            elif typetag == "t":
                cast = None
            elif typetag == "N":
                cast = None
            elif typetag == "I":
                cast = None
            elif typetag == "":
                cast = None

            if cast is not None:
                try:
                    casted = cast(value)
                except ValueError, e:
                    _exit_with_error(
                        "Error converting an argument to type tag" + str(e))
                    return
            else:
                casted = value
            arg = osc.createArgument(casted, typetag)
            verb("Adding argument %s." % (arg))
            message.add(arg)
    except osc.OscError, e:
        _exit_with_error(str(e))
        return None
Exemplo n.º 4
0
 def testCreateFromTypeTag(self):
     self.assertEquals(type(osc.createArgument(123, "T")), osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(123, "F")), osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(123, "N")), osc.NullArgument)
     self.assertEquals(type(osc.createArgument(123, "I")), osc.ImpulseArgument)
     self.assertEquals(type(osc.createArgument(123, "i")), osc.IntArgument)
     self.assertEquals(type(osc.createArgument(123, "f")), osc.FloatArgument)
     self.assertRaises(osc.OscError, osc.createArgument, 123, "?")
Exemplo n.º 5
0
def create_message_manually(path, types, *args):
    """
    The used specified the type tags.
    """
    def _exit_with_error(message):
        global RETURN_VALUE
        if reactor.running:
            reactor.stop()
        print(message)
        RETURN_VALUE = 1 # error
        
    if len(types) != len(args):
        _exit_with_error("The length of the type string must match the number of arguments.")
        return

    message = osc.Message(path)
    try:
        for value, typetag in zip(args, types):
            verb("Creating argument for %s with type tag %s" % (value, typetag))
            cast = str

            if typetag == "i":
                cast = int
            elif typetag == "f":
                cast = float
            elif typetag in ["T", "F"]:
                cast = None
            elif typetag == "t":
                cast = None
            elif typetag == "N":
                cast = None
            elif typetag == "I":
                cast = None
            elif typetag == "":
                cast = None

            if cast is not None:
                try:
                    casted = cast(value)
                except ValueError, e:
                    _exit_with_error("Error converting an argument to type tag" + str(e))
                    return
            else:
                casted = value
            arg = osc.createArgument(casted, typetag)
            verb("Adding argument %s." % (arg))
            message.add(arg)
    except osc.OscError, e:
        _exit_with_error(str(e))
        return None
Exemplo n.º 6
0
 def testCreateFromTypeTag(self):
     self.assertEquals(type(osc.createArgument(123, "T")),
                       osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(123, "F")),
                       osc.BooleanArgument)
     self.assertEquals(type(osc.createArgument(123, "N")), osc.NullArgument)
     self.assertEquals(type(osc.createArgument(123, "I")),
                       osc.ImpulseArgument)
     self.assertEquals(type(osc.createArgument(123, "i")), osc.IntArgument)
     self.assertEquals(type(osc.createArgument(123, "f")),
                       osc.FloatArgument)
     self.assertRaises(osc.OscError, osc.createArgument, 123, "?")