# -*- coding: utf-8 -*-
#                                               -*- Python -*-
#
# @file  core_dispatcher_launcher.py
# @brief launch the core dispatcher on a sample.
#
# (C) Copyright 2005-2012 EDF-EADS-Phimeca
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
# @author souchaud
# @date   2012-08-28
#

import core_dispatcher
import wrapper_data

import os
import sys


if len(sys.argv) == 2:
    host_in_file = sys.argv[1]
else:
    print( 'host_in_file args recquired! exit.' )
    exit(1)

# ensure the core dispatcher will find the in_file
moduledir = os.path.dirname( os.path.realpath( __file__ ) )
os.chdir(moduledir)

wd_host_in = wrapper_data.WrapperDataHostIn()
wd_host_in.set_filename(host_in_file)
wd_host_in.read()

wd_host_out = wrapper_data.WrapperDataHostOut(remote=True)
wd_host_out.set_dirname(wd_host_in.workdir)
wd_host_out.set_hostname(wd_host_in.hostname)

dispatcher = core_dispatcher.CoreDispatcher(wd_host_in, wd_host_out)
dispatcher.exec_sample()
