示例#1
0
 def testEncodeDecodeIterable(self):
     m = OSCMessage()
     m.append((False, (1L, )))
     self.assertEquals(['', ',[F[h]]', [
         False,
         [
             1,
         ],
     ]], decodeOSC(m.getBinary()))
示例#2
0
 def testDispatchUnknownCommand(self):
     message = OSCMessage()
     message.setAddress("/sample/play")
     sampler = RecordingSampler((1,2,'a string'), AttributeError('a'))
     handler = SamplerCallbackManager(sampler)
     # should not throw
     resp = handler.handle(message.getBinary())
     self.assertEquals(resp, "/sampler/error\x00\x00,ss\x00Failed to execute command /sample/play\x00\x00a\x00\x00\x00")
     self.assertEquals([], self.sampler.recorded);
示例#3
0
 def testDispatchInvalidAddress(self):
     message = OSCMessage()
     message.setAddress("/sample/play/invalid")
     # should not throw
     resp = self.handler.handle(message.getBinary())
     
     self.assertEquals(str(resp),
                       "/sampler/error\x00\x00,ss\x00Execution failed\x00\x00\x00\x00"
                       "Invalid address: '/sample/play/invalid', should have two components\x00") 
     self.assertEquals([], self.sampler.recorded);
示例#4
0
    def testDispatchInvalidAddress(self):
        message = OSCMessage()
        message.setAddress("/sample/play/invalid")
        # should not throw
        resp = self.handler.handle(message.getBinary())

        self.assertEquals(
            str(resp),
            "/sampler/error\x00\x00,ss\x00Execution failed\x00\x00\x00\x00"
            "Invalid address: '/sample/play/invalid', should have two components\x00"
        )
        self.assertEquals([], self.sampler.recorded)
示例#5
0
 def testDispatchUnknownCommand(self):
     message = OSCMessage()
     message.setAddress("/sample/play")
     sampler = RecordingSampler((1, 2, 'a string'), AttributeError('a'))
     handler = SamplerCallbackManager(sampler)
     # should not throw
     resp = handler.handle(message.getBinary())
     self.assertEquals(
         resp,
         "/sampler/error\x00\x00,ss\x00Failed to execute command /sample/play\x00\x00a\x00\x00\x00"
     )
     self.assertEquals([], self.sampler.recorded)
示例#6
0
文件: handler.py 项目: svanzoest/aksy
def create_response_msg(address, result):
    msg = OSCMessage()
    msg.setAddress(address)
    if not hasattr(result, '__iter__'):
        result = [result]

    for arg in result:
        msg.append(arg)
    return msg.getBinary()
示例#7
0
 def testEncodeDecodeNone(self):
     m = OSCMessage()
     m.append(None)
     self.assertEquals(['', ',N', None], decodeOSC(m.getBinary()))
示例#8
0
 def testEncodeDecodeTrue(self):
     m = OSCMessage()
     m.append(True)
     self.assertEquals(['', ',T', True], decodeOSC(m.getBinary()))
示例#9
0
 def testEncodeDecodeFalse(self):
     m = OSCMessage()
     m.append(False)
     self.assertEquals(['', ',F', False], decodeOSC(m.getBinary()))
示例#10
0
文件: client.py 项目: svanzoest/aksy
def snd_recv(cmd):
    m = OSCMessage()
    m.setAddress(cmd)
    s.sendall(m.getBinary())
    print decodeOSC(s.recv(8192))
示例#11
0
 def testEncodeDecodeTrue(self):
     m = OSCMessage()
     m.append(True)
     self.assertEquals(['', ',T', True], decodeOSC(m.getBinary()))
示例#12
0
 def testAppendDecodeIterableEmpty(self):
     m = OSCMessage()
     m.append([])
     self.assertEquals(['',',[]',[]], decodeOSC(m.getBinary()))
示例#13
0
 def create_msg(command, args):
     m = OSCMessage()
     m.setAddress("/" + command.section + "/" + command.name)
     for arg in args:
         m.append(arg)
     return m.getBinary()
示例#14
0
 def testDispatch(self):
     message = OSCMessage()
     message.setAddress("/transfertools/get")
     message.append("test.wav")
     response = self.handler.handle(message.getBinary())
     self.assertEquals([["transfertools", "get", ["test.wav"]]], self.sampler.recorded)
     expected = OSCMessage()
     expected.setAddress("/transfertools/get")
     expected.append(1)
     expected.append(2)
     expected.append('a string')
     self.assertEquals(str(expected), response)
示例#15
0
 def testEncodeDecodeBinaryString(self):
     m = OSCMessage()
     m.append("\x00\x01\x02")
     self.assertEquals(['', ',b', "\x00\x01\02"], decodeOSC(m.getBinary()))
示例#16
0
 def testEncodeDecodeInt(self):
     m = OSCMessage()
     m.append(1)
     self.assertEquals(['', ',i', 1], decodeOSC(m.getBinary()))
示例#17
0
 def testAppendDecodeIterableEmpty(self):
     m = OSCMessage()
     m.append([])
     self.assertEquals(['', ',[]', []], decodeOSC(m.getBinary()))
示例#18
0
 def testEncodeDecodeFloat(self):
     m = OSCMessage()
     m.append(1.0)
     self.assertEquals(['', ',f', 1.0], decodeOSC(m.getBinary()))
示例#19
0
 def testEncodeDecodeNone(self):
     m = OSCMessage()
     m.append(None)
     self.assertEquals(['', ',N', None], decodeOSC(m.getBinary()))
示例#20
0
 def testEncodeDecodeFalse(self):
     m = OSCMessage()
     m.append(False)
     self.assertEquals(['', ',F', False], decodeOSC(m.getBinary()))
示例#21
0
 def testEncodeDecodeInt(self):
     m = OSCMessage()
     m.append(1)
     self.assertEquals(['', ',i', 1], decodeOSC(m.getBinary()))
示例#22
0
文件: handler.py 项目: svanzoest/aksy
def create_error_msg(text, exception):
    msg = OSCMessage()
    msg.setAddress('/sampler/error')
    msg.append(text)
    msg.append(str(exception))
    return msg.getBinary()
示例#23
0
 def testEncodeDecodeIterable(self):
     m = OSCMessage()
     m.append((False, (1L,)))
     self.assertEquals(['', ',[F[h]]', [False, [1,],]], decodeOSC(m.getBinary()))
示例#24
0
 def testEncodeDecodeString(self):
     m = OSCMessage()
     m.append("abc")
     self.assertEquals(['', ',s', "abc"], decodeOSC(m.getBinary()))
示例#25
0
 def testEncodeDecodeString(self):
     m = OSCMessage()
     m.append("abc")
     self.assertEquals(['', ',s', "abc"], decodeOSC(m.getBinary()))
示例#26
0
 def testEncodeDecodeFloat(self):
     m = OSCMessage()
     m.append(1.0)
     self.assertEquals(['', ',f', 1.0], decodeOSC(m.getBinary()))
示例#27
0
    def create_alt_req_msg(handle, commands, args, index):
        bundle = OSCMessage()
        bundle.setAddress("")
        bundle.append('#bundle')
        bundle.append(0)
        bundle.append(0)
   
        alt_req = OSCMessage()
        alt_req.setAddress('/altoperations')
        alt_req.append(handle)
        alt_req.append(index)
        bundle.append(alt_req.getBinary(), 'b')

        args = list(args)
        
        for cmd in commands:
            if len(cmd.arg_types) > 0:
                arg = args.pop(0)
            else:
                arg = []
                
            bundle.append(OSCConnector.create_msg(cmd, arg), 'b')
        return bundle.message
示例#28
0
 def testEncodeDecodeLong(self):
     m = OSCMessage()
     m.append(1L)
     self.assertEquals(['', ',h', 1L], decodeOSC(m.getBinary()))
示例#29
0
 def testEncodeDecodeBinaryString(self):
     m = OSCMessage()
     m.append("\x00\x01\x02")
     self.assertEquals(['', ',b', "\x00\x01\02"], decodeOSC(m.getBinary()))
示例#30
0
 def testEncodeDecodeLong(self):
     m = OSCMessage()
     m.append(1L)
     self.assertEquals(['', ',h', 1L], decodeOSC(m.getBinary()))
示例#31
0
def snd_recv(cmd):
    m = OSCMessage()
    m.setAddress(cmd)
    s.sendall(m.getBinary())
    print decodeOSC(s.recv(8192))
示例#32
0
 def testDispatch(self):
     message = OSCMessage()
     message.setAddress("/transfertools/get")
     message.append("test.wav")
     response = self.handler.handle(message.getBinary())
     self.assertEquals([["transfertools", "get", ["test.wav"]]],
                       self.sampler.recorded)
     expected = OSCMessage()
     expected.setAddress("/transfertools/get")
     expected.append(1)
     expected.append(2)
     expected.append('a string')
     self.assertEquals(str(expected), response)