|
38 | 38 | import PySimpleGUI as sg |
39 | 39 | import os |
40 | 40 | import sys |
| 41 | +import subprocess |
41 | 42 | import threading |
42 | 43 | from pathlib import Path, PurePath # Python 3.4 and up |
43 | 44 | import queue |
|
60 | 61 |
|
61 | 62 |
|
62 | 63 | APP_NAME = 'Python Easy Chess GUI' |
63 | | -APP_VERSION = 'v1.8' |
| 64 | +APP_VERSION = 'v1.9' |
64 | 65 | BOX_TITLE = '{} {}'.format(APP_NAME, APP_VERSION) |
65 | 66 |
|
66 | 67 |
|
@@ -441,7 +442,12 @@ def run(self): |
441 | 442 | folder = folder.parents[0] |
442 | 443 |
|
443 | 444 | try: |
444 | | - self.engine = chess.engine.SimpleEngine.popen_uci( |
| 445 | + if platform == 'win32': |
| 446 | + self.engine = chess.engine.SimpleEngine.popen_uci( |
| 447 | + self.engine_path_and_file, cwd=folder, |
| 448 | + creationflags=subprocess.CREATE_NO_WINDOW) |
| 449 | + else: |
| 450 | + self.engine = chess.engine.SimpleEngine.popen_uci( |
445 | 451 | self.engine_path_and_file, cwd=folder) |
446 | 452 | except chess.engine.EngineTerminatedError: |
447 | 453 | logging.warning('Failed to start {}.'.format(self.engine_path_and_file)) |
@@ -844,7 +850,12 @@ def get_engine_id_name(self, path_and_file, q): |
844 | 850 | folder = folder.parents[0] |
845 | 851 |
|
846 | 852 | try: |
847 | | - engine = chess.engine.SimpleEngine.popen_uci( |
| 853 | + if platform == 'win32': |
| 854 | + engine = chess.engine.SimpleEngine.popen_uci( |
| 855 | + path_and_file, cwd=folder, |
| 856 | + creationflags=subprocess.CREATE_NO_WINDOW) |
| 857 | + else: |
| 858 | + engine = chess.engine.SimpleEngine.popen_uci( |
848 | 859 | path_and_file, cwd=folder) |
849 | 860 | id_name = engine.id['name'] |
850 | 861 | engine.quit() |
@@ -1062,8 +1073,13 @@ def add_engine_to_config_file(self, engine_path_and_file, pname, que): |
1062 | 1073 | data = json.load(json_file) |
1063 | 1074 |
|
1064 | 1075 | try: |
1065 | | - engine = chess.engine.SimpleEngine.popen_uci( |
1066 | | - engine_path_and_file, cwd=folder) |
| 1076 | + if platform == 'win32': |
| 1077 | + engine = chess.engine.SimpleEngine.popen_uci( |
| 1078 | + engine_path_and_file, cwd=folder, |
| 1079 | + creationflags=subprocess.CREATE_NO_WINDOW) |
| 1080 | + else: |
| 1081 | + engine = chess.engine.SimpleEngine.popen_uci( |
| 1082 | + engine_path_and_file, cwd=folder) |
1067 | 1083 | except Exception: |
1068 | 1084 | logging.exception('Failed to add {} in config file.'.format(pname)) |
1069 | 1085 | que.put('Failure') |
@@ -1152,10 +1168,15 @@ def check_engine_config_file(self): |
1152 | 1168 | folder = epath.parents[0] |
1153 | 1169 |
|
1154 | 1170 | try: |
1155 | | - engine = chess.engine.SimpleEngine.popen_uci( |
1156 | | - engine_path_and_file, cwd=folder) |
| 1171 | + if platform == 'win32': |
| 1172 | + engine = chess.engine.SimpleEngine.popen_uci( |
| 1173 | + engine_path_and_file, cwd=folder, |
| 1174 | + creationflags=subprocess.CREATE_NO_WINDOW) |
| 1175 | + else: |
| 1176 | + engine = chess.engine.SimpleEngine.popen_uci( |
| 1177 | + engine_path_and_file, cwd=folder) |
1157 | 1178 | except Exception: |
1158 | | - logging.exception('Failed to start engine.') |
| 1179 | + logging.exception(f'Failed to start engine {fn}!') |
1159 | 1180 | continue |
1160 | 1181 |
|
1161 | 1182 | engine_id_name = engine.id['name'] |
|
0 commit comments