From a379c36e89a680f85ca96133469b7a94105cad44 Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Fri, 29 Jun 2018 23:42:34 -0400 Subject: [PATCH] Support for engines which output into stderr --- Client/OpenBench.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Client/OpenBench.py b/Client/OpenBench.py index 3264ea8..12ae32e 100644 --- a/Client/OpenBench.py +++ b/Client/OpenBench.py @@ -204,12 +204,18 @@ def getCutechessCommand(data, scalefactor): def singleCoreBench(name, outqueue): try: - # Format file path because of Windows .... + # Format file path because of Windows ... dir = os.path.join('Engines', getNameAsExe(name)) - # Last two lines should hold node count and NPS - data = os.popen('{0} bench'.format(dir)).read() - data = data.strip().split('\n') + # Run bench from CMD, pipe stderr into stdout + data, empty = subprocess.Popen( + '{0} bench'.format(dir).split(), + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ).communicate() + + # Split line by line after decoding + data = data.decode('ascii').strip().split('\n') # Parse and dump results into queue bench = int(data[-2].split(':')[1])