Esempio n. 1
0
import os
import sys
from collections import namedtuple
from pychess.System.cpu import get_cpu

# Constants
AUTO_DETECT = True
NO_AUTO_DETECT = False

# CPUID
cpu = get_cpu()

# List of known interpreters
PYTHONBIN = sys.executable.split("/")[-1]
VM = namedtuple('VM', 'name, ext, args')
VM_LIST = [
    VM("node", ".js", None),
    VM("java", ".jar", ["-jar"]),
    VM(PYTHONBIN, ".py", ["-u"])
]

# Needed by shutil.which() on Windows to find .py engines
if cpu['windows']:
    for vm in VM_LIST:
        if vm.ext.upper() not in os.getenv("PATHEXT"):
            os.environ["PATHEXT"] += ";%s" % vm.ext.upper()

# List of engines later sorted by descending length of name
# The comments provides known conflicts with Linux packages
# Weak engines (<2700) should be added manually unless a package exists already
if cpu['windows']:
Esempio n. 2
0
                    need_mvcount = True
                    break
            if need_mvcount:
                mvcount = "%d..." % (ply // 2)
            else:
                mvcount = ""
        else:
            mvcount = ""
    return mvcount


def load(handle, progressbar=None):
    return PGNFile(handle, progressbar)


cpuinfo = get_cpu()
MODERN = "-modern" if cpuinfo['popcnt'] else ""

altpath = getEngineDataPrefix()

scoutfish = "scoutfish_x%s%s%s" % (cpuinfo['bitness'], MODERN,
                                   cpuinfo['binext'])
scoutfish_path = shutil.which(scoutfish, mode=os.X_OK, path=altpath)

parser = "parser_x%s%s%s" % (cpuinfo['bitness'], MODERN, cpuinfo['binext'])
chess_db_path = shutil.which(parser, mode=os.X_OK, path=altpath)


class PGNFile(ChessFile):
    def __init__(self, handle, progressbar=None):
        ChessFile.__init__(self, handle)