|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import zipfile |
| 4 | +from pathlib import Path |
| 5 | +from subprocess import call |
| 6 | +from typing import * |
| 7 | + |
| 8 | +import evalfen |
| 9 | +from getFile import downloadName, getAvailableNames |
| 10 | +from send import sendFile, sendNotification |
| 11 | + |
| 12 | +STOCKFISH_DOWNLOAD = { |
| 13 | + "win32": "https://stockfishchess.org/files/stockfish-11-win.zip", |
| 14 | + "linux": "https://stockfishchess.org/files/stockfish-11-linux.zip", |
| 15 | + "linux32": "https://stockfishchess.org/files/stockfish-11-linux.zip", |
| 16 | + "darwin": "https://stockfishchess.org/files/stockfish-11-mac.zip" |
| 17 | +} |
| 18 | + |
| 19 | + |
| 20 | +def unzip(filepath, resultpath): |
| 21 | + with zipfile.ZipFile(filepath, 'r') as zip_ref: |
| 22 | + zip_ref.extractall(resultpath) |
| 23 | + |
| 24 | + |
| 25 | +def promptNames(names: List[str]) -> str: |
| 26 | + for i, name in enumerate(names): |
| 27 | + print(i, name, sep='\t') |
| 28 | + uin = int(input("Which number? ")) |
| 29 | + return names[uin] |
| 30 | + |
| 31 | + |
| 32 | +def promptDownload() -> bool: |
| 33 | + uin = input("Do you need to download any other dataset?(y)es/(n)o ") |
| 34 | + return 'y' in uin |
| 35 | + |
| 36 | + |
| 37 | +def downloadStockfish() -> None: |
| 38 | + link = STOCKFISH_DOWNLOAD[sys.platform] |
| 39 | + call(["curl", "-o", "stockfish.zip", link]) |
| 40 | + unzip("stockfish.zip", "stockfish/") |
| 41 | + |
| 42 | + |
| 43 | +def findStockfish() -> Path: |
| 44 | + pass |
| 45 | + |
| 46 | + |
| 47 | +def promptStockfish() -> Path: |
| 48 | + uin = input("Do you have stockfish in your current directory?(y)es/(n)o ") |
| 49 | + needsfish = 'y' in uin |
| 50 | + if needsfish: |
| 51 | + downloadStockfish() |
| 52 | + |
| 53 | + |
| 54 | +def main() -> None: |
| 55 | + if promptDownload(): |
| 56 | + names = list(getAvailableNames()) |
| 57 | + names.sort() |
| 58 | + name = promptNames(names) |
| 59 | + downloadName(name) |
| 60 | + print("Done for now") |
| 61 | + |
| 62 | + |
| 63 | +if __name__ == "__main__": |
| 64 | + main() |
0 commit comments