Skip to content

Instantly share code, notes, and snippets.

@nhthn
Created September 13, 2019 05:11
Show Gist options
  • Save nhthn/870f95c9ff1a256b0273ad3aa3950d75 to your computer and use it in GitHub Desktop.
Save nhthn/870f95c9ff1a256b0273ad3aa3950d75 to your computer and use it in GitHub Desktop.
sclang communication test
import sys
import subprocess
proc = subprocess.Popen(
["sclang", "-i", "scqt"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
def read_line():
if proc.returncode is not None:
sys.exit(0)
string = proc.stdout.readline().decode("utf-8")
print(string[:-1])
return string
def evaluate_code(string):
raw = string.encode("utf-8") + b"\x1b"
proc.stdin.write(raw)
proc.stdin.flush()
evaluate_code(""" "Execution at startup is working".postln; """)
line = read_line()
while "Welcome to" not in line:
line = read_line()
evaluate_code(""" "Execution at boot is working".postln; """)
read_line()
read_line()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment