-
-
Save zeffii/7410984 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 | |
# subprocess.call(["chuck", "foo.ck", "bar.ck"]) | |
import time | |
ck_exe = "chuck.exe" | |
ck_dir = os.getcwd(); | |
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() | |
ck_dir = "C:/Program Files/ChucK/bin" | |
print('start the beast') | |
chuck_process = subprocess.Popen([ck_exe, '--loop'], | |
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 foo.ck') | |
chuck_process.stdin.write("foo.ck") | |
#chuck_process.stdin.flush() | |
time.sleep(7) | |
#print('add bar.ck') | |
#chuck_process.stdin.write("+bar.ck\n") | |
#time.sleep(2) | |
#chuck_process.stdin.flush() | |
# chuck_process.stdin.write("--halt") | |
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