-
-
Save zeffii/7606278 to your computer and use it in GitHub Desktop.
This file contains 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
# get it to function first, then add threading | |
# http://docs.python.org/3.1/library/threading.html | |
# http://docs.python.org/3.1/library/subprocess.html | |
import sys | |
import subprocess | |
import os | |
import threading | |
from queue import Queue, Empty | |
ck_exe = "chuck.exe" | |
#ck_dir = os.getcwd(); | |
ck_dir = "C:/Program Files2/ChucK/bin" | |
ON_POSIX = 'posix' in sys.builtin_module_names | |
def enqueue_output(out, queue): | |
for line in iter(out.readline, b''): | |
queue.put(line) | |
out.close() | |
print('start the beast') | |
chuck_process = subprocess.Popen([ck_exe, '--shell'], | |
cwd=ck_dir, | |
bufsize=1, | |
close_fds=ON_POSIX, | |
stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.STDOUT, | |
universal_newlines=True, | |
shell=True) | |
chuck_queue = Queue() | |
chuck_thread = threading.Thread( | |
target=enqueue_output, | |
args=(chuck_process.stdout, chuck_queue)) | |
chuck_thread.daemon = True # thread dies with the program | |
chuck_thread.start() | |
print('add Mooo2.ck') | |
chuck_process.stdin.write("+ Mooo2.ck") | |
chuck_process.stdin.write("\x0c") # is like hitting Enter/Return | |
#chuck_process.stdin.flush() | |
print('add Mooo.ck') | |
chuck_process.stdin.write("+ Mooo.ck") | |
chuck_process.stdin.write("\x0c") | |
#chuck_process.stdin.write("--kill") | |
#chuck_process.stdin.flush() | |
print('end') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment