Created
February 20, 2016 07:37
-
-
Save redraw/0eca6e58126311510ce2 to your computer and use it in GitHub Desktop.
pyOSC wrapper to send OSC messages from the terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from OSC import OSCClient, OSCMessage | |
import argparse | |
class Client: | |
"""pyOSC Client Wrapper""" | |
def __init__(self, host=None, port=None): | |
self.host = host | |
self.port = port | |
self.c = OSCClient() | |
self.c.connect((host, port)) | |
def send(self, address, message=None): | |
msg = OSCMessage(address) | |
if message: msg.append(message) | |
self.c.send(msg) | |
def close(self): | |
self.c.close() | |
def main(args): | |
client = Client(args.host, args.port) | |
client.send(args.address, args.msg) | |
client.close() | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='pyOSC Client Wrapper') | |
parser.add_argument('--host', default="127.0.0.1") | |
parser.add_argument('-p', '--port', type=int, required=True) | |
parser.add_argument('address') | |
parser.add_argument('msg', nargs='*') | |
args = parser.parse_args() | |
main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment