Initial Commit

main
andrew.vanderbye 9 months ago
commit 4558a6284d
  1. 19
      README
  2. 7
      client.py
  3. 23
      server.py
  4. 2
      test.bat

@ -0,0 +1,19 @@
# OSC-TO_SCRIPT
## GETTING STARTED
- Create directory for project to live in
- Drop Batch Files to execute into the project directory
- Navigate to this folder in terminal/command prompt
- Run the following commands
> \<PATH TO PYTHON>/python.exe -m venv venv
>
> \<PATH TO PROJECT>/venv/Scripts/activate.bat
>
> pip install python-osc
To run the server:
> "\<PATH TO PROJECT>/venv/Scripts/python.exe" "\<PATH TO PROJECT>/server.py"
OR
> "\<PATH TO PROJECT>/venv/Scripts/pythonw.exe" "\<PATH TO PROJECT>/server.py"

@ -0,0 +1,7 @@
from pythonosc.udp_client import SimpleUDPClient
ip = "127.0.0.1"
port = 1337
client = SimpleUDPClient(ip, port) # Create client
client.send_message("/script/test.bat", 123) # Send float message

@ -0,0 +1,23 @@
from pythonosc.dispatcher import Dispatcher
from pythonosc.osc_server import BlockingOSCUDPServer
import subprocess
from subprocess import Popen
def default_handler(address, *args):
print(f"DEFAULT {address}: {args}")
def run_script(address, *args):
script_to_run = address.split("/")[-1]
print(f"Script to run: {script_to_run}")
Popen(script_to_run,creationflags=subprocess.CREATE_NEW_CONSOLE)
dispatcher = Dispatcher()
dispatcher.map("/script/*", run_script)
dispatcher.set_default_handler(default_handler)
ip = "127.0.0.1"
port = 1337
server = BlockingOSCUDPServer((ip, port), dispatcher)
server.serve_forever() # Blocks forever

@ -0,0 +1,2 @@
ECHO 'hooray'
PAUSE
Loading…
Cancel
Save