#!/usr/bin/env python

################################################################################
#  
#  Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks
#  The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
#  
#  This file is part of MadAnalysis 5.
#  Official website: <https://launchpad.net/madanalysis5>
#  
#  MadAnalysis 5 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, either version 3 of the License, or
#  (at your option) any later version.
#  
#  MadAnalysis 5 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 MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
#  
################################################################################


################################################################################
# MAIN PROGRAM
################################################################################

"""This is the main executable, a simple frontend to set up the PYTHONPATH
and call immediately the command line interface scripts"""

# Checking if the correct release of Python is installed
import sys
if not sys.version_info[0] == 2 or sys.version_info[1] < 6:
    sys.exit('Python release '+ sys.version + ' is detected.\n' + \
    'MadAnalysis 5 works only with python 2.6 ' + \
    'or later (but not python 3.X).\n' + \
    'Please upgrade your version of python.')

# Getting the parent directory (ma5 root dir) of the script real path (bin)
import os
import commands
import optparse
ma5dir = os.path.split(os.path.dirname(os.path.realpath( __file__ )))[0]
if not os.path.isdir(ma5dir):
    sys.exit('Detected MadAnalysis 5 general folder is not correct:\n' +\
             ma5dir)
os.environ['MA5_BASE']=ma5dir

# Adding the MadAnalysis 5 folder to the current PYTHONPATH
# -> allowing to use MadAnalysis 5 python files
sys.path.insert(0, ma5dir)

# Adding the python service folder to the current PYTHONPATH
servicedir = ma5dir+'/tools/ReportGenerator/Services/'
servicedir = os.path.normpath(servicedir)
if not os.path.isdir(servicedir):
    sys.exit('Detected MadAnalysis 5 service folder is not correct:\n' + ma5dir)
sys.path.insert(0, servicedir)

# Release version
# Do not touch it !!!!!  
version = "1.2"
date = "2015/07/24"

# Loading the MadAnalysis session
import madanalysis.core.launcher
madanalysis.core.launcher.LaunchMA5(version, date, ma5dir)


