diff --git a/Makefile b/Makefile index 5829f8f..2588524 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ py = python3 cc := ${py} -m PyInstaller pgg = dist/gui/pygame_gui -data = ${pgg}/data +data := ${pgg}/data pggdatacdn = https://raw.githubusercontent.com/MyreMylar/pygame_gui/main/pygame_gui/data all: init build data @@ -11,7 +11,7 @@ all: init build data .PHONY: init build data test clean init: - $(py) -m pip install pyinstaller pytest + $(py) -m pip install PyInstaller==3.6 pytest==5.4.3 $(py) -m pip install -r requirements.txt build: diff --git a/gui.py b/gui.py index f45e80b..8eb54b9 100644 --- a/gui.py +++ b/gui.py @@ -10,13 +10,12 @@ from threading import Thread, Lock # Pygame sends a stdout message -actual_stdout = sys.stdout with io.StringIO() as sys.stdout: import cpuinfo import pygame import pygame.gfxdraw import pygame_gui -sys.stdout = actual_stdout +sys.stdout = sys.__stdout__ import lib from core import Database diff --git a/lib/enginelib.py b/lib/enginelib.py index c85289e..8b1b788 100644 --- a/lib/enginelib.py +++ b/lib/enginelib.py @@ -129,7 +129,7 @@ def get_config(default_options={}): try: with open(Path.home() / ".waychess" / "engineoptions.json", 'r') as fin: return { - k: v for k, v in json.loads(fin.read()).items() + k: v for k, v in json.load(fin).items() if k.lower() not in {"ponder", "multipv", "uci_chess960"} } except FileNotFoundError: @@ -149,6 +149,14 @@ def configure_engine_options(self): path.touch() self.stdout("[ENGINE CONFIGURE", webbrowser.open(str(path))) + def reconfigure_engine(self): + try: + self.engine.configure(get_config({ + k: v.default for k, v in self.engine.options.items() + })) + except Exception as e: + self.stderr("[EGNINE RECONFIGURE]", e) + def set_analysis(self): self.stdout("Set engine task") beg = time.time() @@ -161,9 +169,7 @@ def set_analysis(self): self.stdout("Failed due to", e) self.exit() self.stdout("Loading engine options") - self.engine.configure(get_config({ - k: v.default for k, v in self.engine.options.items() - })) + self.reconfigure_engine() self.is_analysing = True self.show_engine = True self.analysis_display = GUIAnalysis(self) @@ -208,6 +214,7 @@ def stop_analysis(self): def engine_callback(self): try: if not self.show_engine: + self.reconfigure_engine() self.set_analysis() else: self.stop_analysis()