#!/usr/bin/python
#
# PyChess startup script
#

import os, sys
if sys.version_info < (2, 5, 0):
    print 'ERROR: PyChess requires Python >= 2.5'
    sys.exit(1)

import pygtk
pygtk.require("2.0")

try:
    import rsvg
except ImportError:
    print 'ERROR: Could not load the rsvg module.'
    print 'You need to install the rsvg package which is called python-rsvg in'
    print 'Debian/Ubuntu and gnome-python2-rsvg in RPM based distributions like Fedora'
    sys.exit(1)

if not "HOME" in os.environ:
    os.environ["HOME"] = os.path.expanduser("~")

# Import datalocation functions and ensure access to codebase
try:
    from pychess.System.prefix import addDataPrefix, getDataPrefix, isInstalled
except ImportError:
    print "ERROR: Could not import modules."
    print "Please try to run pychess as stated in the INSTALL file"
    sys.exit(1)

# Set up translations
import gettext, gtk.glade
if isInstalled():
    gettext.install("pychess", unicode=1, names=('ngettext',))
    gtk.glade.bindtextdomain("pychess")
else:
    gettext.install("pychess", localedir=addDataPrefix("lang"), unicode=1, names=('ngettext',))
    gtk.glade.bindtextdomain("pychess", addDataPrefix("lang"))
gtk.glade.textdomain("pychess")

# Let's rumble!
import pychess.Main
pychess.Main.run(sys.argv[1:])
