This repository has been archived by the owner on Apr 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgns3.pyw
executable file
·83 lines (69 loc) · 2.67 KB
/
gns3.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
# vim: expandtab ts=4 sw=4 sts=4:
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2011 GNS3 Development Team (http://www.gns3.net/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
#
#
import sys, os, time, traceback
try:
reload(sys)
sys.setdefaultencoding('utf-8')
except:
sys.stderr.write("Can't set default encoding to utf-8\n")
# current version of GNS3
VERSION = "0.8.7"
try:
from PyQt4 import QtCore, QtGui
except ImportError:
sys.stderr.write("Can't import Qt modules, PyQt is probably not installed ...\n")
sys.exit(False)
if QtCore.QT_VERSION < 0x040600:
raise RuntimeError, "Need Qt v4.6 or higher, but got v%s" % QtCore.QT_VERSION_STR
if QtCore.PYQT_VERSION < 0x040500:
raise RuntimeError, "Need PyQt v4.5 or higher, but got v%s" % QtCore.PYQT_VERSION_STR
if sys.version_info < (2, 6):
raise RuntimeError, "Python 2.6 or higher is required"
def exceptionHook(type, value, tb):
lines = traceback.format_exception(type, value, tb)
print "---------Traceback lines (saved in exception.log)----------"
print "\n" . join(lines)
print "-----------------------------------------------------------"
try:
curdate = time.strftime("%d %b %Y %H:%M:%S")
logfile = open('exception.log','a')
logfile.write("=== GNS3 " + VERSION + " traceback on " + curdate + " ===\n")
logfile.write("\n" . join(lines))
logfile.close()
except:
pass
# catch exceptions to write them in a file
sys.excepthook=exceptionHook
if __name__ == '__main__':
# __file__ is not supported by py2exe and py2app
if hasattr(sys, "frozen"):
GNS3_RUN_PATH = os.path.dirname(os.path.abspath(sys.executable))
else:
GNS3_RUN_PATH = os.path.dirname(os.path.abspath(__file__))
# change current working directory to GNS3_RUN_PATH for relative paths to work correctly
os.chdir(GNS3_RUN_PATH)
source_path = GNS3_RUN_PATH + os.sep + 'src'
if os.access(source_path, os.F_OK):
sys.path.append(source_path)
if len(sys.argv) > 1 and sys.argv[1].startswith("-psn"):
del sys.argv[1]
import GNS3.Main