Reenable error dialog and remove versioning info - want to look into a more uniform way of doing this if possible, and the requirements are all changing.
This commit is contained in:
@@ -40,6 +40,9 @@ try:
|
||||
except:
|
||||
logbook_version = "Unknown"
|
||||
|
||||
import wx.lib.agw.hyperlink
|
||||
|
||||
|
||||
|
||||
class ErrorFrame(wx.Frame):
|
||||
def __init__(self, exception=None, tb=None, error_title='Error!'):
|
||||
@@ -74,13 +77,11 @@ class ErrorFrame(wx.Frame):
|
||||
descText = wx.StaticText(self, wx.ID_ANY, desc)
|
||||
box.Add(descText, 1, wx.ALL, 5)
|
||||
|
||||
github = wx.HyperlinkCtrl(self, wx.ID_ANY, "Github", "https://github.com/pyfa-org/Pyfa/issues",
|
||||
wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE)
|
||||
box.Add(github, 0, wx.ALL, 5)
|
||||
|
||||
eveForums = wx.HyperlinkCtrl(self, wx.ID_ANY, "EVE Forums", "https://forums.eveonline.com/t/27156",
|
||||
wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE)
|
||||
box.Add(eveForums, 0, wx.ALL, 5)
|
||||
# github = wx.lib.agw.hyperlink.HyperLinkCtrl(self, wx.ID_ANY, label="Github", URL="https://github.com/pyfa-org/Pyfa/issues")
|
||||
# box.Add(github, 0, wx.ALL, 5)
|
||||
#
|
||||
# eveForums = wx.lib.agw.hyperlink.HyperLinkCtrl(self, wx.ID_ANY, label="EVE Forums", URL="https://forums.eveonline.com/t/27156")
|
||||
# box.Add(eveForums, 0, wx.ALL, 5)
|
||||
|
||||
# mainSizer.AddSpacer((0, 5), 0, wx.EXPAND, 5)
|
||||
|
||||
@@ -88,42 +89,42 @@ class ErrorFrame(wx.Frame):
|
||||
errorTextCtrl.SetFont(wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL))
|
||||
mainSizer.Add(errorTextCtrl, 0, wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, 5)
|
||||
|
||||
try:
|
||||
errorTextCtrl.AppendText("OS version: \t" + str(platform.platform()))
|
||||
except:
|
||||
errorTextCtrl.AppendText("OS version: Unknown")
|
||||
errorTextCtrl.AppendText("\n")
|
||||
|
||||
try:
|
||||
errorTextCtrl.AppendText("Python: \t" + '{}.{}.{}'.format(v.major, v.minor, v.micro))
|
||||
except:
|
||||
errorTextCtrl.AppendText("Python: Unknown")
|
||||
errorTextCtrl.AppendText("\n")
|
||||
|
||||
try:
|
||||
errorTextCtrl.AppendText("wxPython: \t" + wx.VERSION_STRING)
|
||||
except:
|
||||
errorTextCtrl.AppendText("wxPython: Unknown")
|
||||
errorTextCtrl.AppendText("\n")
|
||||
|
||||
errorTextCtrl.AppendText("SQLAlchemy: \t" + str(sqlalchemy_version))
|
||||
errorTextCtrl.AppendText("\n")
|
||||
|
||||
errorTextCtrl.AppendText("Logbook: \t" + str(logbook_version))
|
||||
errorTextCtrl.AppendText("\n")
|
||||
|
||||
try:
|
||||
errorTextCtrl.AppendText("pyfa version: {0} {1} - {2} {3}".format(config.version, config.tag, config.expansionName, config.expansionVersion))
|
||||
except:
|
||||
errorTextCtrl.AppendText("pyfa version: Unknown")
|
||||
errorTextCtrl.AppendText('\n')
|
||||
|
||||
errorTextCtrl.AppendText("pyfa root: " + str(config.pyfaPath or "Unknown"))
|
||||
errorTextCtrl.AppendText('\n')
|
||||
errorTextCtrl.AppendText("save path: " + str(config.savePath or "Unknown"))
|
||||
errorTextCtrl.AppendText('\n')
|
||||
errorTextCtrl.AppendText("fs encoding: " + str(sys.getfilesystemencoding() or "Unknown"))
|
||||
errorTextCtrl.AppendText('\n\n')
|
||||
# try:
|
||||
# errorTextCtrl.AppendText("OS version: \t" + str(platform.platform()))
|
||||
# except:
|
||||
# errorTextCtrl.AppendText("OS version: Unknown")
|
||||
# errorTextCtrl.AppendText("\n")
|
||||
#
|
||||
# try:
|
||||
# errorTextCtrl.AppendText("Python: \t" + '{}.{}.{}'.format(v.major, v.minor, v.micro))
|
||||
# except:
|
||||
# errorTextCtrl.AppendText("Python: Unknown")
|
||||
# errorTextCtrl.AppendText("\n")
|
||||
#
|
||||
# try:
|
||||
# errorTextCtrl.AppendText("wxPython: \t" + wx.VERSION_STRING)
|
||||
# except:
|
||||
# errorTextCtrl.AppendText("wxPython: Unknown")
|
||||
# errorTextCtrl.AppendText("\n")
|
||||
#
|
||||
# errorTextCtrl.AppendText("SQLAlchemy: \t" + str(sqlalchemy_version))
|
||||
# errorTextCtrl.AppendText("\n")
|
||||
#
|
||||
# errorTextCtrl.AppendText("Logbook: \t" + str(logbook_version))
|
||||
# errorTextCtrl.AppendText("\n")
|
||||
#
|
||||
# try:
|
||||
# errorTextCtrl.AppendText("pyfa version: {0} {1} - {2} {3}".format(config.version, config.tag, config.expansionName, config.expansionVersion))
|
||||
# except:
|
||||
# errorTextCtrl.AppendText("pyfa version: Unknown")
|
||||
# errorTextCtrl.AppendText('\n')
|
||||
#
|
||||
# errorTextCtrl.AppendText("pyfa root: " + str(config.pyfaPath or "Unknown"))
|
||||
# errorTextCtrl.AppendText('\n')
|
||||
# errorTextCtrl.AppendText("save path: " + str(config.savePath or "Unknown"))
|
||||
# errorTextCtrl.AppendText('\n')
|
||||
# errorTextCtrl.AppendText("fs encoding: " + str(sys.getfilesystemencoding() or "Unknown"))
|
||||
# errorTextCtrl.AppendText('\n\n')
|
||||
|
||||
errorTextCtrl.AppendText("EXCEPTION: " + str(exception or "Unknown"))
|
||||
errorTextCtrl.AppendText('\n\n')
|
||||
|
||||
183
pyfa.py
183
pyfa.py
@@ -51,8 +51,6 @@ ascii_text = '''
|
||||
|_| |___/
|
||||
|
||||
You are running a alpha/beta version of pyfa.
|
||||
If you run into problems, please let me know at:
|
||||
https://github.com/pyfa-org/Pyfa/issues
|
||||
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
'''
|
||||
@@ -95,87 +93,88 @@ class PassThroughOptionParser(OptionParser):
|
||||
# self.level(sys.stderr)
|
||||
#
|
||||
#
|
||||
# class PreCheckException(Exception):
|
||||
# def __init__(self, msg):
|
||||
# try:
|
||||
# ln = sys.exc_info()[-1].tb_lineno
|
||||
# except AttributeError:
|
||||
# ln = inspect.currentframe().f_back.f_lineno
|
||||
# self.message = "{0.__name__} (line {1}): {2}".format(type(self), ln, msg)
|
||||
# self.args = self.message,
|
||||
#
|
||||
#
|
||||
# def handleGUIException(exc_type, exc_value, exc_traceback):
|
||||
# try:
|
||||
# # Try and import wx in case it's missing.
|
||||
# # noinspection PyPackageRequirements
|
||||
# import wx
|
||||
# from gui.errorDialog import ErrorFrame
|
||||
# except:
|
||||
# # noinspection PyShadowingNames
|
||||
# wx = None
|
||||
# # noinspection PyShadowingNames
|
||||
# ErrorFrame = None
|
||||
#
|
||||
# tb = traceback.format_tb(exc_traceback)
|
||||
#
|
||||
# try:
|
||||
#
|
||||
# # Try and output to our log handler
|
||||
# with logging_setup.threadbound():
|
||||
# module_list = list(set(sys.modules) & set(globals()))
|
||||
# if module_list:
|
||||
# pyfalog.info("Imported Python Modules:")
|
||||
# for imported_module in module_list:
|
||||
# module_details = sys.modules[imported_module]
|
||||
# pyfalog.info("{0}: {1}", imported_module, getattr(module_details, '__version__', ''))
|
||||
#
|
||||
# pyfalog.critical("Exception in main thread: {0}", exc_value.message)
|
||||
# # Print the base level traceback
|
||||
# traceback.print_tb(exc_traceback)
|
||||
#
|
||||
# if wx and ErrorFrame:
|
||||
# pyfa_gui = wx.App(False)
|
||||
# if exc_type == PreCheckException:
|
||||
# msgbox = wx.MessageBox(exc_value.message, 'Error', wx.ICON_ERROR | wx.STAY_ON_TOP)
|
||||
# msgbox.ShowModal()
|
||||
# else:
|
||||
# ErrorFrame(exc_value, tb)
|
||||
#
|
||||
# pyfa_gui.MainLoop()
|
||||
#
|
||||
# pyfalog.info("Exiting.")
|
||||
# except:
|
||||
# # Most likely logging isn't available. Try and output to the console
|
||||
# module_list = list(set(sys.modules) & set(globals()))
|
||||
# if module_list:
|
||||
# pyfalog.info("Imported Python Modules:")
|
||||
# for imported_module in module_list:
|
||||
# module_details = sys.modules[imported_module]
|
||||
# print((str(imported_module) + ": " + str(getattr(module_details, '__version__', ''))))
|
||||
#
|
||||
# print(("Exception in main thread: " + str(exc_value.message)))
|
||||
# traceback.print_tb(exc_traceback)
|
||||
#
|
||||
# if wx and ErrorFrame:
|
||||
# pyfa_gui = wx.App(False)
|
||||
# if exc_type == PreCheckException:
|
||||
# msgbox = wx.MessageBox(exc_value.message, 'Error', wx.ICON_ERROR | wx.STAY_ON_TOP)
|
||||
# msgbox.ShowModal()
|
||||
# else:
|
||||
# ErrorFrame(exc_value, tb)
|
||||
#
|
||||
# pyfa_gui.MainLoop()
|
||||
#
|
||||
# print("Exiting.")
|
||||
#
|
||||
# finally:
|
||||
# # TODO: Add cleanup when exiting here.
|
||||
# sys.exit()
|
||||
#
|
||||
#
|
||||
# # Replace the uncaught exception handler with our own handler.
|
||||
# sys.excepthook = handleGUIException
|
||||
class PreCheckException(Exception):
|
||||
def __init__(self, msg):
|
||||
try:
|
||||
ln = sys.exc_info()[-1].tb_lineno
|
||||
except AttributeError:
|
||||
ln = inspect.currentframe().f_back.f_lineno
|
||||
self.message = "{0.__name__} (line {1}): {2}".format(type(self), ln, msg)
|
||||
self.args = self.message,
|
||||
|
||||
|
||||
def handleGUIException(exc_type, exc_value, exc_traceback):
|
||||
try:
|
||||
# Try and import wx in case it's missing.
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.errorDialog import ErrorFrame
|
||||
except:
|
||||
# noinspection PyShadowingNames
|
||||
wx = None
|
||||
# noinspection PyShadowingNames
|
||||
ErrorFrame = None
|
||||
|
||||
tb = traceback.format_tb(exc_traceback)
|
||||
|
||||
try:
|
||||
|
||||
# Try and output to our log handler
|
||||
with logging_setup.threadbound():
|
||||
module_list = list(set(sys.modules) & set(globals()))
|
||||
if module_list:
|
||||
pyfalog.info("Imported Python Modules:")
|
||||
for imported_module in module_list:
|
||||
module_details = sys.modules[imported_module]
|
||||
pyfalog.info("{0}: {1}", imported_module, getattr(module_details, '__version__', ''))
|
||||
|
||||
pyfalog.critical("Exception in main thread: {0}", str(exc_value))
|
||||
# Print the base level traceback
|
||||
traceback.print_tb(exc_traceback)
|
||||
|
||||
if wx and ErrorFrame:
|
||||
pyfa_gui = wx.App(False)
|
||||
if exc_type == PreCheckException:
|
||||
msgbox = wx.MessageBox(str(exc_value), 'Error', wx.ICON_ERROR | wx.STAY_ON_TOP)
|
||||
msgbox.ShowModal()
|
||||
else:
|
||||
ErrorFrame(exc_value, tb)
|
||||
|
||||
pyfa_gui.MainLoop()
|
||||
|
||||
pyfalog.info("Exiting.")
|
||||
except Exception as ex:
|
||||
# Most likely logging isn't available. Try and output to the console
|
||||
module_list = list(set(sys.modules) & set(globals()))
|
||||
if module_list:
|
||||
pyfalog.info("Imported Python Modules:")
|
||||
for imported_module in module_list:
|
||||
module_details = sys.modules[imported_module]
|
||||
print((str(imported_module) + ": " + str(getattr(module_details, '__version__', ''))))
|
||||
|
||||
print(("Exception in main thread: " + str(exc_value)))
|
||||
traceback.print_tb(exc_traceback)
|
||||
|
||||
if wx and ErrorFrame:
|
||||
pyfa_gui = wx.App(False)
|
||||
if exc_type == PreCheckException:
|
||||
msgbox = wx.MessageBox(str(exc_value), 'Error', wx.ICON_ERROR | wx.STAY_ON_TOP)
|
||||
msgbox.ShowModal()
|
||||
else:
|
||||
ErrorFrame(exc_value, tb)
|
||||
|
||||
pyfa_gui.MainLoop()
|
||||
|
||||
print("Exiting.")
|
||||
|
||||
finally:
|
||||
# TODO: Add cleanup when exiting here.
|
||||
pass
|
||||
# sys.exit()
|
||||
|
||||
|
||||
# Replace the uncaught exception handler with our own handler.
|
||||
sys.excepthook = handleGUIException
|
||||
|
||||
# Parse command line options
|
||||
usage = "usage: %prog [--root]"
|
||||
@@ -294,10 +293,11 @@ if __name__ == "__main__":
|
||||
with logging_setup.threadbound():
|
||||
pyfalog.info("Starting Pyfa")
|
||||
|
||||
pyfalog.info("Logbook version: {0}", logbook_version)
|
||||
# pyfalog.info("Logbook version: {0}", logbook_version)
|
||||
|
||||
pyfalog.info("Running in logging mode: {0}", logging_mode)
|
||||
pyfalog.info("Writing log file to: {0}", config.logPath)
|
||||
# pyfalog.info("Running in logging mode: {0}", logging_mode)
|
||||
# move this to the log set up - if it fails, can't say that we're writing it
|
||||
# pyfalog.info("Writing log file to: {0}", config.logPath)
|
||||
|
||||
# Output all stdout (print) messages as warnings
|
||||
# try:
|
||||
@@ -311,9 +311,9 @@ if __name__ == "__main__":
|
||||
# except:
|
||||
# pyfalog.critical("Cannot redirect. Continuing without writing stderr to log.")
|
||||
|
||||
pyfalog.info("OS version: {0}", platform.platform())
|
||||
|
||||
pyfalog.info("Python version: {0}", sys.version)
|
||||
# pyfalog.info("OS version: {0}", platform.platform())
|
||||
#
|
||||
# pyfalog.info("Python version: {0}", sys.version)
|
||||
# if sys.version_info < (2, 7) or sys.version_info > (3, 0):
|
||||
# exit_message = "Pyfa requires python 2.x branch ( >= 2.7 )."
|
||||
# raise PreCheckException(exit_message)
|
||||
@@ -344,7 +344,7 @@ if __name__ == "__main__":
|
||||
exit_message = "Cannot import wxPython. You can download wxPython (2.8+) from http://www.wxpython.org/"
|
||||
# raise PreCheckException(exit_message)
|
||||
|
||||
pyfalog.info("wxPython version: {0}.", str(wx.VERSION_STRING))
|
||||
#pyfalog.info("wxPython version: {0}.", str(wx.VERSION_STRING))
|
||||
|
||||
if sqlalchemy is None:
|
||||
exit_message = "\nCannot find sqlalchemy.\nYou can download sqlalchemy (0.6+) from http://www.sqlalchemy.org/"
|
||||
@@ -363,7 +363,8 @@ if __name__ == "__main__":
|
||||
pyfalog.critical("You can download sqlAlchemy (0.5.8+) from http://www.sqlalchemy.org/")
|
||||
pyfalog.critical("Attempting to run with unsupported version of sqlAlchemy.")
|
||||
else:
|
||||
pyfalog.info("Current version of sqlAlchemy is: {0}", sqlalchemy.__version__)
|
||||
pass
|
||||
# pyfalog.info("Current version of sqlAlchemy is: {0}", sqlalchemy.__version__)
|
||||
else:
|
||||
pyfalog.warning("Unknown sqlalchemy version string format, skipping check. Version: {0}", sqlalchemy.__version__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user