18 |
import traceback |
import traceback |
19 |
|
|
20 |
from wxPython.wx import * |
from wxPython.wx import * |
|
from wxPython.lib.dialogs import wxScrolledMessageDialog |
|
21 |
|
|
22 |
from Thuban.Lib.connector import Publisher |
from Thuban.Lib.connector import Publisher |
23 |
from Thuban.Lib.fileutil import get_application_dir |
from Thuban.Lib.fileutil import get_application_dir |
33 |
import view |
import view |
34 |
import tree |
import tree |
35 |
import mainwindow |
import mainwindow |
36 |
|
import dbdialog |
37 |
|
import exceptiondialog |
38 |
|
|
39 |
from messages import SESSION_REPLACED |
from messages import SESSION_REPLACED |
40 |
|
|
196 |
# get problems when saving because the saving code expects an |
# get problems when saving because the saving code expects an |
197 |
# absolute directory name |
# absolute directory name |
198 |
filename = os.path.abspath(filename) |
filename = os.path.abspath(filename) |
199 |
|
if db_connection_callback is None: |
200 |
|
db_connection_callback = self.run_db_param_dialog |
201 |
try: |
try: |
202 |
session = load_session(filename, |
session = load_session(filename, |
203 |
db_connection_callback=db_connection_callback) |
db_connection_callback=db_connection_callback) |
223 |
dlg.Destroy() |
dlg.Destroy() |
224 |
break |
break |
225 |
|
|
226 |
|
def run_db_param_dialog(self, parameters, message): |
227 |
|
"""Implementation of the db_connection_callback for loading sessions""" |
228 |
|
dlg = dbdialog.DBDialog(None, _("DB Connection Parameters"), |
229 |
|
parameters, message) |
230 |
|
return dlg.RunDialog() |
231 |
|
|
232 |
|
|
233 |
def SaveSession(self): |
def SaveSession(self): |
234 |
save_session(self.session, self.session.filename) |
save_session(self.session, self.session.filename) |
235 |
|
|
236 |
def maps_changed(self, *args): |
def maps_changed(self, *args): |
237 |
|
"""Subscribed to the session's MAPS_CHANGED messages. |
238 |
|
|
239 |
|
Set the toplevel window's map to the map in the session. This is |
240 |
|
done by calling the window's SetMap method with the map as |
241 |
|
argument. If the session doesn't have any maps None is used |
242 |
|
instead. |
243 |
|
|
244 |
|
Currently Thuban can only really handle at most one map in a |
245 |
|
sessions so the first map in the session's list of maps as |
246 |
|
returned by the Maps method is used. |
247 |
|
""" |
248 |
if self.session.HasMaps(): |
if self.session.HasMaps(): |
249 |
self.top.SetMap(self.session.Maps()[0]) |
self.top.SetMap(self.session.Maps()[0]) |
250 |
else: |
else: |
270 |
try: |
try: |
271 |
lines = traceback.format_exception(exc_type, exc_value, |
lines = traceback.format_exception(exc_type, exc_value, |
272 |
exc_traceback) |
exc_traceback) |
273 |
message = "An unhandled exception occurred:\n%s\n" % exc_value+\ |
message = _("An unhandled exception occurred:\n%s\n") % exc_value+\ |
274 |
"(please report to " \ |
_("(please report to") +\ |
275 |
"http://thuban.intevation.org/bugtracker.html)"\ |
" http://thuban.intevation.org/bugtracker.html)"\ |
276 |
"\n\n\n"+\ |
"\n\n\n"+\ |
277 |
"".join(lines) |
"".join(lines) |
278 |
print message |
print message |
280 |
# We don't use an explicit parent here because this method might |
# We don't use an explicit parent here because this method might |
281 |
# be called in circumstances where the main window doesn't exist |
# be called in circumstances where the main window doesn't exist |
282 |
# anymore. |
# anymore. |
283 |
dlg = wxScrolledMessageDialog(None, message, |
exceptiondialog.run_exception_dialog(None, message) |
|
"Thuban: Internal Error") |
|
|
dlg.ShowModal() |
|
|
dlg.Destroy() |
|
284 |
|
|
285 |
finally: |
finally: |
286 |
self.in_exception_dialog = 0 |
self.in_exception_dialog = 0 |