#!/usr/local/bin/python2.5
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 GNS-3 Dev Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 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 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Contact: developers@gns3.net
#

import sys, os, traceback

try:
    from PyQt4 import QtCore,  QtGui
except ImportError:
    sys.stderr.write("PyQt is not installed, please see the README\n")
    sys.exit(False)

if QtCore.QT_VERSION < 0x040300:
    raise RuntimeError, "Need Qt v4.3 or higher, but got v%s" % QtCore.QT_VERSION_STR

if QtCore.PYQT_VERSION < 0x040300:
    sys.stderr.write("Warning: need PyQt v4.3 or higher, but got v%s\n" % QtCore.PYQT_VERSION_STR)
    #raise RuntimeError, "Need PyQt v4.3 or higher, but got v%s" % QtCore.PYQT_VERSION_STR
    
def exceptionHook(type, value, tb):

    lines = traceback.format_exception(type, value, tb)
    print "---------Traceback lines (saved in exception.log)----------"
    print "\n" . join(lines)
    print "-----------------------------------------------------------"
    logfile = open('exception.log','a')
    logfile.write("\n" . join(lines))
    logfile.close()

# catch exceptions to write them in a file
sys.excepthook=exceptionHook
if os.access('./src', os.F_OK):
    sys.path.append('./src')
import GNS3.Main
