forked from danielepantaleone/eddy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·178 lines (145 loc) · 6.75 KB
/
run.py
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##########################################################################
# #
# Eddy: a graphical editor for the specification of Graphol ontologies #
# Copyright (C) 2015 Daniele Pantaleone <[email protected]> #
# #
# This program 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 3 of the License, or #
# (at your option) any later version. #
# #
# 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, see <http://www.gnu.org/licenses/>. #
# #
# ##################### ##################### #
# #
# Graphol is developed by members of the DASI-lab group of the #
# Dipartimento di Ingegneria Informatica, Automatica e Gestionale #
# A.Ruberti at Sapienza University of Rome: http://www.dis.uniroma1.it #
# #
# - Domenico Lembo <[email protected]> #
# - Valerio Santarelli <[email protected]> #
# - Domenico Fabio Savo <[email protected]> #
# - Daniele Pantaleone <[email protected]> #
# - Marco Console <[email protected]> #
# #
##########################################################################
import platform
import os
import sys
import jnius_config
from eddy.core.functions.path import expandPath
_LINUX = sys.platform.startswith('linux')
_MACOS = sys.platform.startswith('darwin')
_WIN32 = sys.platform.startswith('win32')
#############################################
# BEGIN JVM SETUP
#################################
if os.path.isdir(expandPath('@resources/java/')):
os.environ['JAVA_HOME'] = expandPath('@resources/java/')
if _WIN32:
path = os.getenv('Path', '')
path = path.split(os.pathsep)
path.insert(0, os.path.join(os.environ['JAVA_HOME'], 'jre', 'bin', 'client'))
os.environ['Path'] = os.pathsep.join(path)
classpath = []
resources = expandPath('@resources/lib/')
for name in os.listdir(resources):
path = os.path.join(resources, name)
if os.path.isfile(path):
classpath.append(path)
jnius_config.add_options('-ea', '-Xmx512m')
jnius_config.set_classpath(*classpath)
#############################################
# BEGIN ENVIRONMENT SPECIFIC SETUP
#################################
if _LINUX:
os.environ['LD_LIBRARY_PATH'] = expandPath('@root/')
if hasattr(sys, 'frozen'):
os.environ['REQUESTS_CA_BUNDLE'] = expandPath('@root/cacert.pem')
from PyQt5 import Qt
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets
from argparse import ArgumentParser
from sip import SIP_VERSION_STR
from eddy import APPNAME, COPYRIGHT, VERSION, BUG_TRACKER
from eddy.core.application import Eddy
from eddy.core.functions.misc import format_exception
from eddy.core.functions.signals import connect
from eddy.core.output import getLogger
from eddy.ui import fonts_rc
from eddy.ui import images_rc
app = None
msgbox = None
LOGGER = getLogger()
def base_except_hook(exc_type, exc_value, exc_traceback):
"""
Used to handle all uncaught exceptions.
:type exc_type: class
:type exc_value: Exception
:type exc_traceback: Traceback
"""
if issubclass(exc_type, KeyboardInterrupt):
app.quit()
else:
global msgbox
if not msgbox:
LOGGER.critical(format_exception(exc_value))
msgbox = QtWidgets.QMessageBox()
msgbox.setIconPixmap(QtGui.QPixmap(':/images/eddy-sad'))
msgbox.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
msgbox.setWindowTitle('Fatal error!')
msgbox.setText('This is embarrassing ...\n\n' \
'A critical error has just occurred. {0} will continue to work, ' \
'however a reboot is highly recommended.'.format(APPNAME))
msgbox.setInformativeText('If the problem persists you can '
'<a href="{0}">submit a bug report</a>.'.format(BUG_TRACKER))
msgbox.setDetailedText(format_exception(exc_value))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Close | QtWidgets.QMessageBox.Ok)
buttonOk = msgbox.button(QtWidgets.QMessageBox.Ok)
buttonOk.setText('Close')
buttonQuit = msgbox.button(QtWidgets.QMessageBox.Close)
buttonQuit.setText('Quit {0}'.format(APPNAME))
connect(buttonOk.clicked, msgbox.close)
connect(buttonQuit.clicked, app.quit)
# noinspection PyArgumentList
QtWidgets.QApplication.beep()
msgbox.exec_()
msgbox = None
def main():
"""
Application entry point.
"""
parser = ArgumentParser()
parser.add_argument('--nosplash', dest='nosplash', action='store_true')
parser.add_argument('--tests', dest='tests', action='store_true')
parser.add_argument('--open', dest='open', default=None)
sys.excepthook = base_except_hook
options, _ = parser.parse_known_args(args=sys.argv)
global app
app = Eddy(options, sys.argv)
if app.isRunning():
sys.exit(0)
LOGGER.separator(separator='-')
LOGGER.frame('%s v%s', APPNAME, VERSION, separator='|')
LOGGER.frame(COPYRIGHT, separator='|')
LOGGER.separator(separator='-')
LOGGER.frame('OS: %s %s', platform.system(), platform.release(), separator='|')
LOGGER.frame('Python version: %s', platform.python_version(), separator='|')
LOGGER.frame('Qt version: %s', QtCore.QT_VERSION_STR, separator='|')
LOGGER.frame('PyQt version: %s', Qt.PYQT_VERSION_STR, separator='|')
LOGGER.frame('SIP version: %s', SIP_VERSION_STR, separator='|')
LOGGER.separator(separator='-')
app.configure(options)
app.start(options)
sys.exit(app.exec_())
if __name__ == '__main__':
main()