|
@ -29,6 +29,9 @@ print("Using world_name: " + wn) |
|
|
print() |
|
|
print() |
|
|
process = None |
|
|
process = None |
|
|
try: |
|
|
try: |
|
|
|
|
|
# get both stdout and stderr (see |
|
|
|
|
|
# https://www.saltycrane.com/blog/2008/09/how-get-stdout-and- |
|
|
|
|
|
# stderr-using-python-subprocess-module/) |
|
|
process = subprocess.Popen( |
|
|
process = subprocess.Popen( |
|
|
[mts, '--gameid', game_id, '--worldname', wn], |
|
|
[mts, '--gameid', game_id, '--worldname', wn], |
|
|
stdout=subprocess.PIPE, |
|
|
stdout=subprocess.PIPE, |
|
@ -48,7 +51,7 @@ for flag in msg_flags: |
|
|
|
|
|
|
|
|
def print_unique_only(output): |
|
|
def print_unique_only(output): |
|
|
output_strip = output.strip() |
|
|
output_strip = output.strip() |
|
|
# (output_original is bytes) |
|
|
# (out_bytes is bytes) |
|
|
show_enable = True |
|
|
show_enable = True |
|
|
found_flag = None |
|
|
found_flag = None |
|
|
f_i = None |
|
|
f_i = None |
|
@ -79,16 +82,17 @@ def process_msg(bstring): |
|
|
|
|
|
|
|
|
while True: |
|
|
while True: |
|
|
try: |
|
|
try: |
|
|
output_original = process.stdout.readline() |
|
|
# out_bytes = process.stdout.readline() |
|
|
err_original = process.stderr.readline() |
|
|
# err_bytes = process.stderr.readline() |
|
|
if (output_original == '') and \ |
|
|
out_bytes, err_bytes = p.communicate() |
|
|
(err_original == '') and \ |
|
|
if (out_bytes == '') and \ |
|
|
|
|
|
(err_bytes == '') and \ |
|
|
(process.poll() is not None): |
|
|
(process.poll() is not None): |
|
|
break |
|
|
break |
|
|
if output_original: |
|
|
if out_bytes: |
|
|
process_msg(output_original) |
|
|
process_msg(out_bytes) |
|
|
if err_original: |
|
|
if err_bytes: |
|
|
process_msg(err_original) |
|
|
process_msg(err_bytes) |
|
|
rc = process.poll() |
|
|
rc = process.poll() |
|
|
except KeyboardInterrupt: |
|
|
except KeyboardInterrupt: |
|
|
break |
|
|
break |
|
|