Skip to content
Permalink
Browse files

Merge pull request pyfa-org#1048 from Ebag333/ErrorDialog_and_miscfixes

Error Dialog improvements and Pyfa.py refactoring
  • Loading branch information...
blitzmann committed Apr 11, 2017
2 parents 82f6d26 + 48db3c8 commit 47ea12f4ba2faa6922e993147c64b765f24b1c42
@@ -27,7 +27,9 @@
from logbook import Logger

pyfalog = Logger(__name__)

pyfalog.info("Initializing database")
pyfalog.info("Gamedata connection: {0}", config.gamedata_connectionstring)
pyfalog.info("Saveddata connection: {0}", config.saveddata_connectionstring)

class ReadOnlyException(Exception):
pass
@@ -86,8 +88,10 @@ class ReadOnlyException(Exception):
# If using in memory saveddata, you'll want to reflect it so the data structure is good.
if config.saveddata_connectionstring == "sqlite:///:memory:":
saveddata_meta.create_all()
pyfalog.info("Running database out of memory.")


def rollback():
with sd_lock:
pyfalog.warning("Session rollback triggered.")
saveddata_session.rollback()
@@ -544,10 +544,12 @@ def __runCommandBoosts(self, runTime="normal"):

if warfareBuffID == 21: # Skirmish Burst: Interdiction Maneuvers: Tackle Range
groups = ("Stasis Web", "Warp Scrambler")
self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, "maxRange", value, stackingPenalties=True)
self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, "maxRange", value,
stackingPenalties=True)

if warfareBuffID == 22: # Skirmish Burst: Rapid Deployment: AB/MWD Speed Increase
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Afterburner") or mod.item.requiresSkill("High Speed Maneuvering"),
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Afterburner") or
mod.item.requiresSkill("High Speed Maneuvering"),
"speedFactor", value, stackingPenalties=True)

if warfareBuffID == 23: # Mining Burst: Mining Laser Field Enhancement: Mining/Survey Range
@@ -556,7 +558,8 @@ def __runCommandBoosts(self, runTime="normal"):
mod.item.requiresSkill("Gas Cloud Harvesting"),
"maxRange", value, stackingPenalties=True)

self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("CPU Management"), "surveyScanRange", value, stackingPenalties=True)
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("CPU Management"),
"surveyScanRange", value, stackingPenalties=True)

if warfareBuffID == 24: # Mining Burst: Mining Laser Optimization: Mining Capacitor/Duration
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining") or
@@ -570,7 +573,8 @@ def __runCommandBoosts(self, runTime="normal"):
"duration", value, stackingPenalties=True)

if warfareBuffID == 25: # Mining Burst: Mining Equipment Preservation: Crystal Volatility
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining"), "crystalVolatilityChance", value, stackingPenalties=True)
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining"),
"crystalVolatilityChance", value, stackingPenalties=True)

if warfareBuffID == 60: # Skirmish Burst: Evasive Maneuvers: Agility
self.ship.boostItemAttr("agility", value, stackingPenalties=True)
@@ -17,23 +17,40 @@
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# ===============================================================================

import wx
import platform
import sys
import gui.utils.fonts as fonts
import config

# noinspection PyPackageRequirements
import wx

try:
import config
except:
config = None

try:
import sqlalchemy

sqlalchemy_version = sqlalchemy.__version__
except:
sqlalchemy_version = "Unknown"

try:
from logbook import __version__ as logbook_version
except:
logbook_version = "Unknown"


class ErrorFrame(wx.Frame):
def __init__(self, exception=None, tb=None, error_title='Error!'):
v = sys.version_info

def __init__(self, exception, tb):
wx.Frame.__init__(self, None, id=wx.ID_ANY, title="pyfa error", pos=wx.DefaultPosition, size=wx.Size(500, 400),
wx.Frame.__init__(self, None, id=wx.ID_ANY, title="pyfa error", pos=wx.DefaultPosition, size=wx.Size(500, 600),
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER | wx.STAY_ON_TOP)

desc = "pyfa has experienced an unexpected error. Below is the " \
"Traceback that contains crucial information about how this " \
"error was triggered. Please contact the developers with " \
"the information provided through the EVE Online forums " \
"or file a GitHub issue."
desc = "pyfa has experienced an unexpected issue. Below is a message that contains crucial\n" \
"information about how this was triggered. Please contact the developers with the\n" \
"information provided through the EVE Online forums or file a GitHub issue."

self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

@@ -43,47 +60,78 @@ def __init__(self, exception, tb):
mainSizer = wx.BoxSizer(wx.VERTICAL)
headSizer = wx.BoxSizer(wx.HORIZONTAL)

self.headingText = wx.StaticText(self, wx.ID_ANY, "Error!", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE)
self.headingText.SetFont(wx.Font(14, 74, 90, 92, False))
headingText = wx.StaticText(self, wx.ID_ANY, error_title, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE)
headingText.SetFont(wx.Font(14, 74, 90, 92, False))

headSizer.Add(self.headingText, 1, wx.ALL, 5)
headSizer.Add(headingText, 1, wx.ALL, 5)
mainSizer.Add(headSizer, 0, wx.EXPAND, 5)

mainSizer.Add(wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND | wx.ALL, 5)

descSizer = wx.BoxSizer(wx.HORIZONTAL)
self.descText = wx.TextCtrl(self, wx.ID_ANY, desc, wx.DefaultPosition, wx.DefaultSize,
wx.TE_AUTO_URL | wx.TE_MULTILINE | wx.TE_READONLY | wx.BORDER_NONE | wx.TRANSPARENT_WINDOW)
self.descText.SetFont(wx.Font(fonts.BIG, wx.SWISS, wx.NORMAL, wx.NORMAL))
descSizer.Add(self.descText, 1, wx.ALL, 5)
mainSizer.Add(descSizer, 1, wx.EXPAND, 5)

self.eveForums = wx.HyperlinkCtrl(self, wx.ID_ANY, "EVE Forums Thread", "https://forums.eveonline.com/default.aspx?g=posts&t=466425",
wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE)
box = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(box, 0, wx.EXPAND | wx.ALIGN_TOP)

mainSizer.Add(self.eveForums, 0, wx.ALL, 2)
descText = wx.StaticText(self, wx.ID_ANY, desc)
box.Add(descText, 1, wx.ALL, 5)

self.eveForums = wx.HyperlinkCtrl(self, wx.ID_ANY, "Github Issues", "https://github.com/pyfa-org/Pyfa/issues",
wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE)
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)

mainSizer.Add(self.eveForums, 0, wx.ALL, 2)
eveForums = wx.HyperlinkCtrl(self, wx.ID_ANY, "EVE Forums", "https://forums.eveonline.com/default.aspx?g=posts&t=466425",
wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE)
box.Add(eveForums, 0, wx.ALL, 5)

# mainSizer.AddSpacer((0, 5), 0, wx.EXPAND, 5)

self.errorTextCtrl = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2 | wx.TE_DONTWRAP)
self.errorTextCtrl.SetFont(wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL))
mainSizer.Add(self.errorTextCtrl, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)

self.errorTextCtrl.AppendText("pyfa root: ")
self.errorTextCtrl.AppendText(config.pyfaPath or "Unknown")
self.errorTextCtrl.AppendText('\n')
self.errorTextCtrl.AppendText("save path: ")
self.errorTextCtrl.AppendText(config.savePath or "Unknown")
self.errorTextCtrl.AppendText('\n')
self.errorTextCtrl.AppendText("fs encoding: ")
self.errorTextCtrl.AppendText(sys.getfilesystemencoding())
self.errorTextCtrl.AppendText('\n\n')
self.errorTextCtrl.AppendText(tb)
errorTextCtrl = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, (-1, 400), wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2 | wx.TE_DONTWRAP)
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')

errorTextCtrl.AppendText("EXCEPTION: " + str(exception or "Unknown"))
errorTextCtrl.AppendText('\n\n')

if tb:
for line in tb:
errorTextCtrl.AppendText(line)
errorTextCtrl.Layout()

self.SetSizer(mainSizer)
mainSizer.Layout()

0 comments on commit 47ea12f

Please sign in to comment.
You can’t perform that action at this time.