commit
4558a6284d
@ -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 |
Loading…
Reference in new issue