#!/usr/bin/python

#
# Copyright 2011 Facundo Batista
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, 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 this program.  If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check  https://launchpad.net/encuentro

"""Script to run Encuentro."""

import sys
import os

# this will be replaced at install time
INSTALLED_BASE_DIR = "/usr/share/encuentro"

# get the replaced-at-install-time name if exists, or the project one
if os.path.exists(INSTALLED_BASE_DIR):
    project_basedir = INSTALLED_BASE_DIR
else:
    project_basedir = os.path.abspath(os.path.dirname(os.path.dirname(
                                            os.path.realpath(sys.argv[0]))))

# first of all, show the versions
print "Running Python %s on %r" % (sys.version_info, sys.platform)
version_file = os.path.join(project_basedir, 'version.txt')
if os.path.exists(version_file):
    print "Encuentro: v. %s" % (open(version_file).read().strip(),)
else:
    print "Encuentro: sin revno info"

if project_basedir not in sys.path:
    sys.path.insert(0, project_basedir)

from encuentro import logger
logger.set_up()

from encuentro import EncuentroUI

from twisted.internet import reactor

EncuentroUI()
reactor.run()
