#!/bin/bash
# #
# Copyright 2009-2015 Ghent University
#
# This file is part of hanythingondemand
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en),
# the Hercules foundation (http://www.herculesstichting.be/in_English)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/hanythingondemand
#
# hanythingondemand is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# hanythingondemand is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with hanythingondemand. If not, see <http://www.gnu.org/licenses/>.
# #

# Python 2.6 or more recent 2.x required
REQ_MAJ_PYVER=2
REQ_MIN_PYVER=6
REQ_PYVER=${REQ_MAJ_PYVER}.${REQ_MIN_PYVER}

# make sure Python version being used is compatible
pyver=`python -V 2>&1 | cut -f2 -d' '`
pyver_maj=`echo $pyver | cut -f1 -d'.'`
pyver_min=`echo $pyver | cut -f2 -d'.'`

if [ $pyver_maj -ne $REQ_MAJ_PYVER ]
then
    echo "ERROR: hanythingondemand is currently only compatible with Python v${REQ_MAJ_PYVER}.x, found v${pyver}" 1>&2
    exit 1
fi
if [ $pyver_min -lt $REQ_MIN_PYVER ]
then
    echo "ERROR: hanythingondemand requires Python v${REQ_PYVER} or a more recent v${REQ_MAJ_PYVER}.x, found v${pyver}." 1>&2
    exit 2
fi

python -O -m hod.main $@
