#!/usr/bin/python
# -*- coding: utf-8 -*-
# 
# Scenic
# Copyright (C) 2008 Société des arts technologiques (SAT)
# http://www.sat.qc.ca
# All rights reserved.
#
# This file 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 2 of the License, or
# (at your option) any later version.
#
# Scenic 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 Scenic. If not, see <http://www.gnu.org/licenses/>.
"""
Executable script which calls scenic.runner.run()

Note that the i18n does not work when not installed.
"""
import os
import sys

SCRIPTS_DIR = "scripts"
PYTHON_LIB_PATH = """@PYTHON_LIB_PATH@"""

def _is_in_devel():
    d = os.path.split(os.path.dirname(os.path.abspath(__file__)))[1]
    #print d
    return d == SCRIPTS_DIR

if __name__ == "__main__":
    if _is_in_devel():
        verbose = False
        if verbose:
            print(">>>>>>>>>>>>>>>>>>> SCENIC DEVEL MODE <<<<<<<<<<<<<<<<<<<")
        d = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
        sys.path.insert(0, d)
        if verbose:
            print("Added %s to Python sys.path." % (d))
        scripts_dir_full_path = os.path.join(d, SCRIPTS_DIR)
        os.environ["PATH"] += ":%s" % (scripts_dir_full_path)
        if verbose:
            print("Added %s to $PATH." % (scripts_dir_full_path))
        from scenic import configure
        configure.replace_install_paths_with_devel_paths()
    else:
        from scenic import configure

    from scenic import runner
    runner.run()

