#!/usr/bin/python

import sys
import os,os.path

def check_version():
  if sys.version_info < (2,4,0):
    # This is a bad start, but let's see if there is a python2.4 around:
    backup_plan = False
    if "PATH" in os.environ:
      for dir in os.environ["PATH"].split(os.pathsep):
        if os.path.exists(dir + os.sep + "python2.4"):
          backup_plan = True

    if not backup_plan:
      print "Unfortunately you need Python 2.4 or later to run Switzerland."
      print "Please install Python 2.4+"
      print "(or send us a patch so that Switzerland runs with your version of Python ;)"
      sys.exit(1)
    else:
      print "It looks like Python2.4 is installed on your system, but it is not the"
      print 'default Python version.  Try running switzerland using "python2.4" '
      print 'instead of "python"'
      sys.exit(0)


check_version()
try:
    from switzerland.client import Alice
except ImportError:
    import sys
    sys.path.append('/usr/local/lib/python2.5/site-packages/')
    sys.path.append('/usr/lib/python2.5/site-packages/')
    sys.path.append('.')

    try:
        from switzerland.client import Alice
    except ImportError, ie:
        print >> sys.stderr, \
              ie.message
        print >> sys.stderr, \
              'Error: cannot load client. Please check your $PYTHONPATH.'
        sys.exit(1)

try:
    Alice.main()
except KeyboardInterrupt:
    pass
