#!/space/truffles/2/users/rlaplant/.canopyrc/User/bin/python

import os
import sys 

#pyside can cause problems with old versions of enable
#however, forcing traits to use pyqt causes problems in anaconda
#We will let the user set this optionally, it is good for debugging to not set.

#os.environ['QT_API']='pyqt'
#os.environ['QT_API']='pyside'

#One or the other should usually be set so that matplotlib and pyface can
#communicate and use the right Qt backend
#pyside is a better default choice

scriptdir=os.getcwd()
python_cmd = 'pythonw' if sys.platform=='darwin' else 'python'
#arguments = '%s %s'%(scriptdir, " ".join(sys.argv[1:]))
#exec_cmd = "%s main.py %s" % (python_cmd, arguments)

arguments = '%s main.py %s %s' % (python_cmd, scriptdir, " ".join(sys.argv[1:]))

try:
    #see if cvu extracted locally 
    os.chdir(os.path.join(os.path.dirname(os.path.dirname(
        os.path.realpath(__file__))),'cvu'))
    os.system(arguments)

except OSError:
    #see if cvu installed to system python

    from cvu.main import main
    sys.argv = arguments.split()
    main()
