Skip to content

Commit

Permalink
added some path error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
DESKTOP-N58MB14\Thomas committed Oct 17, 2020
1 parent f7ed966 commit 5a9cc7d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lichess_elite_db/
*.pyc
stockfish_20090216_x64_avx2.exe
stockfish_20090216_x64_bmi2.exe
4 changes: 2 additions & 2 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

# points to the location of the .pgn files from the lichess elite db from a reddit user
# found at https://www.reddit.com/r/chess/comments/gz8acg/introducing_the_lichess_elite_database/
LICHESS_DB = Path(r"E:\paper_repos\tj-chess\lichess_elite_db")
LICHESS_DB = Path(r"D:/")

STOCKFISH_ENGINE_PATH = Path(r"E:\paper_repos\tj-chess\stockfish_20090216_x64_avx2.exe")
STOCKFISH_ENGINE_PATH = Path(r"D:\paper_repos\tj-chess\stockfish_20090216_x64_bmi2.exe")

# ********** ********** #
4 changes: 3 additions & 1 deletion src/gui/pyqt_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class chessMainWindow(QMainWindow):
def __init__(self):
super().__init__()
if not cfg.LICHESS_DB.exists() or not cfg.LICHESS_DB.exists():
raise ValueError("The paths in config.py need to be configured for your system.")
self.title = 'Chess Viewer and Player'
self.left = 0
self.top = 0
Expand Down Expand Up @@ -52,7 +54,7 @@ def viewer_open_file_btn_click(self):
fname = Path(str(fname[0]))
self.viewer_pgn_file_txt.setText(str(fname))

if Path(self.viewer_pgn_file_txt.text()).exists:
if Path(self.viewer_pgn_file_txt.text()).exists() and Path(self.viewer_pgn_file_txt.text()).suffix == '.pgn':
# open game file
pgn_file = open(Path(self.viewer_pgn_file_txt.text()))
self.viewer_games = []
Expand Down

0 comments on commit 5a9cc7d

Please sign in to comment.