From 8e3f4d2361d50fa6bc00db79d33a8ebd3071bebb Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sat, 26 Oct 2013 12:53:42 -1000 Subject: [PATCH] Server Generator: Combine stdout and stderr to be compatible with post-1.6.4 servers. Change "Done" line to be compatible with the same. Use atexit.register to try to terminate the server when MCEdit exits. --- minecraft_server.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/minecraft_server.py b/minecraft_server.py index dd6b93a..545ad12 100644 --- a/minecraft_server.py +++ b/minecraft_server.py @@ -1,3 +1,4 @@ +import atexit import itertools import logging import os @@ -348,7 +349,7 @@ class MCServerChunkGenerator(object): startTime = time.time() proc = self.runServer(tempDir) while proc.poll() is None: - line = proc.stderr.readline().strip() + line = proc.stdout.readline().strip() log.info(line) yield line @@ -360,7 +361,7 @@ class MCServerChunkGenerator(object): # Forge/FML: # 2012-11-13 11:47:13 [INFO] [Minecraft] Done (8.020s)! - if "[INFO]" in line and "Done" in line: + if "INFO" in line and "Done" in line: if simulate: duration = time.time() - startTime @@ -508,9 +509,11 @@ class MCServerChunkGenerator(object): cwd=startingDir, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + stderr=subprocess.STDOUT, universal_newlines=True, ) + + atexit.register(proc.terminate) return proc def _serverVersion(self): @@ -526,7 +529,7 @@ class MCServerChunkGenerator(object): # for line in err.split("\n"): while proc.poll() is None: - line = proc.stderr.readline() + line = proc.stdout.readline() if "Preparing start region" in line: break if "Starting minecraft server version" in line: