forked from Pidgeot/python-lnp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If program crashes, attempt to log exception to stderr and show in me…
…ssage box
- Loading branch information
Showing
1 changed file
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
"""This file is used to launch the program.""" | ||
from __future__ import absolute_import | ||
from __future__ import absolute_import, print_function | ||
import sys, os | ||
from core import lnp | ||
sys.path.insert(0, os.path.dirname(__file__)) | ||
#pylint: disable=redefined-builtin | ||
#pylint: disable=redefined-builtin, bare-except | ||
__package__ = "" | ||
|
||
lnp.PyLNP() | ||
try: | ||
lnp.PyLNP() | ||
except: | ||
import traceback | ||
message = traceback.format_exception(*sys.exc_info()) | ||
#Log exception to stderr if possible | ||
try: | ||
print(message, file=sys.stderr) | ||
except: | ||
pass | ||
|
||
# Also show error in Tkinter message box if possible | ||
try: | ||
if sys.version_info[0] == 3: # Alternate import names | ||
# pylint:disable=import-error | ||
import tkinter.messagebox as messagebox | ||
else: | ||
# pylint:disable=import-error | ||
import tkMessageBox as messagebox | ||
messagebox.showerror(message=message) | ||
except: | ||
pass |