Esempio n. 1
0
def _connect():
    settings = _read_settings()
    client = OSCClient(settings['ion-ip'], int(settings['ion-port']))
    try:
        client.connect()
    except (socket.timeout, TimeoutError, ConnectionRefusedError):
        return None
    return client
Esempio n. 2
0
    def __init__(self, streamclass="something"):
        self.client = OSCClient()
        self.client.connect(("localhost", 11661))
        self.title = "Something went wrong"
        try:
            print "argv[0] " + sys.argv[0]
            print "getcwd " + os.getcwd()
            path = os.getcwd() + "/" + sys.argv[0]
            path = path.replace("main.py", "")
            manifest = open(path + "manifest.json")
            data = simplejson.load(manifest)
            self.title = data["name"]
            self.creator = data["creator"]
            self.description = data["description"]
            manifest.close()
        except:
            print "Hey we died"

        self.framenumber = 0
        self.streamclass = streamclass
Esempio n. 3
0
# Argument handling
parser = argparse.ArgumentParser(
    description="Run a specific chroma animation script.")
parser.add_argument('animation',
                    metavar='animation',
                    help='One of these animations: ' +
                    string.join(os.listdir('animations/'), ', '),
                    choices=os.listdir('animations/'))
args = parser.parse_args()
animation = args.animation

# Open emulator if there's no OSC responsive on that port already
try:
    sys.path.append("./osc")
    from osc import OSCClient, OSCMessage
    s = OSCClient()
    s.connect(('localhost', 11661))
    # asychronous, so send a bunch to get a potential exception.
    for x in range(10):
        s.send(OSCMessage("poop"))
except Exception, e:
    if '[Errno 61]' in str(e):
        print "Starting emulator, since it doesn't seem to be running yet."
        os.system('emulator/lights_emulator > /dev/null &')
        emu_up = False
        while not emu_up:
            try:
                # asychronous, so send a bunch to get a potential exception.
                for x in range(10):
                    s.send(OSCMessage("poop"))
                emu_up = True
Esempio n. 4
0
from osc import OSCMessage, OSCBundle, OSCClient, OSCServer

message = OSCMessage(address='/message/address')

# argument can be string, int, float, bool and binary
message.add('Some text argument')
message.add(3)
message.add(0.75)
message.add(True)

# create osc bundle and add a message
bundle = OSCBundle()
bundle.add(message)

# create client and send to 127.0.0.1:8000
client = OSCClient('127.0.0.1', 8000)
client.send(message)
client.send(bundle)

# bind server and listen for incoming messages at 127.0.0.1:8000
server = OSCServer('127.0.0.1', 8000)
server.serve_forever()
#!/usr/bin/python
from osc import OSCServer, OSCClient, OSCMessage
import sys








if __name__ == "__main__":
    if len(sys.argv) < 2:
        print """
sendcommand.py: sends commands to the running oscapi.py daemon.
usage: ./sendcommand.py command
available commands:
    reloadconfig - reloads config.py in the octoapi - usually reordering the lights
"""
        sys.exit(-1)
    messagename = sys.argv[1] 
    client = OSCClient()
    client.connect( ("localhost",11661) )
    message = OSCMessage('/'+messagename)
    for param in sys.argv[2:]:
        message.append(param)
    client.send( message )