#!/usr/bin/python
# -*- coding: utf-8 -*-
# -*- mode: python -*-
# vim:si:ai:et:sw=4:sts=4:ts=4
#
# copyright Nicolas Bertrand (nico@inattendu.org), 2010
#
# this file is part of luciole.
#
#    the free software foundation, either version 3 of the license, or
#    (at your option) any later version.
#
#    luciole 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 luciole.  if not, see <http://www.gnu.org/licenses/>.
#
#
"""
luciole launcher 

"""


import sys, os

# get the real location of this launcher file (not the link location)
realfile = os.path.realpath(__file__)
realfile_dir = os.path.dirname(os.path.abspath(realfile))

# determine if running from the /openshot/bin folder
parent_folder_path = os.path.dirname(realfile_dir)
bin_path = os.path.join(parent_folder_path, 'luciole')
if os.path.exists(os.path.join(bin_path, 'main.py')):
    # insert this path into the Python path
    sys.path.insert(0, parent_folder_path)
    print "Added %s to system path" % parent_folder_path
else:
    
    # determine if running from the /usr/share/openshot folder
    usr_share_path = os.path.join('/', 'usr', 'share', 'luciole')
    if os.path.exists(usr_share_path):
        # insert this path into the Python path
        sys.path.insert(0, usr_share_path)
        print "Added %s to system path" % usr_share_path


try :
    import luciole.main as X
    X.main()

except ImportError, err:
    print err
    raise ImportError 
