Skip to content

Commit

Permalink
Specify pyinstaller version in makefile, make engine autorefresh conf…
Browse files Browse the repository at this point in the history
…iguration
  • Loading branch information
r2dev2 committed Nov 7, 2020
1 parent 697af09 commit 5d9f00c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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

.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:
Expand Down
3 changes: 1 addition & 2 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions lib/enginelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5d9f00c

Please sign in to comment.