diff options
author | Andrés Ambrois <andresambrois@gmail.com> | 2008-08-16 09:15:34 (GMT) |
---|---|---|
committer | Andrés Ambrois <andresambrois@gmail.com> | 2008-08-16 09:15:34 (GMT) |
commit | 6200c1437f278640f4c94f6ccfc9aeaeedf0e7ba (patch) | |
tree | a401aab52b4cdd6d20a64dae60b201e7123f82fb | |
parent | 11cf6c6a268b17c02df7673c846ba991a04842fa (diff) |
gtp.search_for_gnugo() checks if gnugo is installed
-rw-r--r-- | gtp.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -19,8 +19,19 @@ from subprocess import Popen, PIPE import logging +from os.path import exists, join, abspath +from os import pathsep, environ +from string import split + logger = logging.getLogger('PlayGo') +def search_for_gnugo(): + paths = split(environ['PATH'], pathsep) + for path in paths: + if exists(join(path, 'gnugo')): + return abspath(join(path, 'gnugo')) + return False + class gnugo: ''' A wrapper for talking to gnugo over GTP ''' def __init__(self, boardsize=19, color='black', handicap=0, komi=5.5, level=3): |