# HG changeset patch # User sirebral # Date 1251057426 18000 # Node ID dd4be48173776d2afdf954020c953e8bb6e8c977 # Parent 57887ab0df510b8177eb0a70ab6a0897fa75b724 Chat Window no longer prints excessive debug statements to console. Renamed the Update Manager menu item to Traipse Suite. Added debug console to Traipse Suite. Log now prints an error report and waits for user input so Windows users can see the error being reported. diff -r 57887ab0df51 -r dd4be4817377 orpg/chat/chatwnd.py --- a/orpg/chat/chatwnd.py Sat Aug 22 05:29:56 2009 -0500 +++ b/orpg/chat/chatwnd.py Sun Aug 23 14:57:06 2009 -0500 @@ -148,7 +148,8 @@ # !id : @debugging def __init__(self, parent, id): - wx.html.HtmlWindow.__init__(self, parent, id, style=wx.SUNKEN_BORDER | wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE) + wx.html.HtmlWindow.__init__(self, parent, id, + style=wx.SUNKEN_BORDER|wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE) self.parent = parent self.build_menu() self.Bind(wx.EVT_LEFT_UP, self.LeftUp) @@ -237,10 +238,8 @@ @debugging def __init__(self, parent, id): wx.webview.WebView.__init__(self, parent, id) - self.parent = parent self.__font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName='Ariel') - self.build_menu() self.Bind(wx.EVT_LEFT_UP, self.LeftUp) self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup) @@ -265,7 +264,9 @@ @debugging def SetDefaultFontAndSize(self, fontname, fontsize): - self.__font = wx.Font(int(fontsize), wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName=fontname) + self.__font = wx.Font(int(fontsize), + wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, + wx.FONTWEIGHT_NORMAL, faceName=fontname) try: self.SetPageSource(self.Header() + self.StripHeader()) except Exception, e: print e return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) @@ -374,8 +375,7 @@ self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.onPageChanging) self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onCloseTab) # html font/fontsize is global to all the notebook tabs. - self.font, self.fontsize = self.MainChatPanel.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), - self.settings.get_setting('defaultfontsize')) + self.font, self.fontsize = self.MainChatPanel.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), self.settings.get_setting('defaultfontsize')) self.GMChatPanel = None if self.settings.get_setting("GMWhisperTab") == '1': self.create_gm_tab() @@ -524,7 +524,8 @@ @debugging def __init__(self, parent, id, tab_type, sendtarget): - wx.Panel.__init__(self, parent, id) + wx.Panel.__init__(self, parent, id) + logger._set_log_to_console(False) self.session = component.get('session') self.settings = component.get('settings') self.activeplugins = component.get('plugins') @@ -572,7 +573,8 @@ @debugging def set_default_font(self, fontname=None, fontsize=None): - """Set all chatpanels to new default fontname/fontsize. Returns current font settings in a (fontname, fontsize) tuple.""" + """Set all chatpanels to new default fontname/fontsize. + Returns current font settings in a (fontname, fontsize) tuple.""" if (fontname is not None): newfont = fontname else: newfont = self.font if (fontsize is not None): newfontsize = int(fontsize) @@ -1291,7 +1293,7 @@ ## END elif event.GetKeyCode() == wx.WXK_END: - logger.debug("event.GetKeyCode() == wx.WXK_END", ORPG_DEBUG) + logger.debug("event.GetKeyCode() == wx.WXK_END") if self.lockscroll: self.lock_scroll(0) self.Post() @@ -1299,7 +1301,7 @@ ## NOTHING else: event.Skip() - logger.debug("Exit chat_panel->OnChar(self, event)", ORPG_DEBUG) + logger.debug("Exit chat_panel->OnChar(self, event)") # def OnChar - end @debugging diff -r 57887ab0df51 -r dd4be4817377 orpg/main.py --- a/orpg/main.py Sat Aug 22 05:29:56 2009 -0500 +++ b/orpg/main.py Sun Aug 23 14:57:06 2009 -0500 @@ -57,7 +57,7 @@ from orpg.tools.orpg_settings import settings from orpg.tools.validate import validate from orpg.tools.passtool import PassTool -from orpg.tools.orpg_log import logger +from orpg.tools.orpg_log import logger, crash from orpg.tools.decorators import debugging from orpg.tools.metamenus import MenuBarEx @@ -137,6 +137,11 @@ logger.debug("update manager reloaded") self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + #Load Update Manager + component.add('debugconsole', self.debugger) + logger.debug("debugger window") + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + @debugging def post_show_init(self): """Some Actions need to be done after the main fram is drawn""" @@ -255,12 +260,17 @@ self.pluginMenu.AppendSeparator() self.mainmenu.Insert(2, self.pluginMenu, "&Plugins") - self.updateMana = wx.Menu() - mana = wx.MenuItem(self.updateMana, wx.ID_ANY, "Update Manager", "Update Manager") + # Traipse Suite of Additions. + self.traipseSuite = wx.Menu() + self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite") + + mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager") self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana) + self.traipseSuite.AppendItem(mana) - self.updateMana.AppendItem(mana) - self.mainmenu.Insert(5, self.updateMana, "&Update Manager") + debugger = wx.MenuItem(self.traipseSuite, -1, "Debug Console", "Debug Console") + self.Bind(wx.EVT_MENU, self.OnMB_DebugConsole, debugger) + self.traipseSuite.AppendItem(debugger) ################################# @@ -463,6 +473,11 @@ else: self.updateMana.Show() @debugging + def OnMB_DebugConsole(self, evt): + if self.debugger.IsShown() == True: self.debugger.Hide() + else: self.debugger.Show() + + @debugging def OnMB_ToolsLoggingLevelDebug(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG @@ -640,6 +655,18 @@ self.SetDimensions(posx, posy, w, h) logger.debug("Dimensions Set") + #Update Manager + self.manifest = manifest.ManifestChanges() + self.debugger = orpg.tools.orpg_log.DebugConsole(self) + logger.debug("Menu Created") + h = int(xml_dom.getAttribute("height")) + w = int(xml_dom.getAttribute("width")) + posx = int(xml_dom.getAttribute("posx")) + posy = int(xml_dom.getAttribute("posy")) + maximized = int(xml_dom.getAttribute("maximized")) + self.SetDimensions(posx, posy, w, h) + logger.debug("Dimensions Set") + # Sound Manager self.sound_player = orpg.tools.orpg_sound.orpgSound(self) component.add("sound", self.sound_player) diff -r 57887ab0df51 -r dd4be4817377 orpg/orpg_version.py --- a/orpg/orpg_version.py Sat Aug 22 05:29:56 2009 -0500 +++ b/orpg/orpg_version.py Sun Aug 23 14:57:06 2009 -0500 @@ -4,7 +4,7 @@ #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed) DISTRO = "Traipse Dev" DIS_VER = "Ornery Orc" -BUILD = "090822-02" +BUILD = "090823-00" # This version is for network capability. PROTOCOL_VERSION = "1.2" diff -r 57887ab0df51 -r dd4be4817377 orpg/tools/orpg_log.py --- a/orpg/tools/orpg_log.py Sat Aug 22 05:29:56 2009 -0500 +++ b/orpg/tools/orpg_log.py Sun Aug 23 14:57:06 2009 -0500 @@ -25,11 +25,11 @@ # # Description: classes for orpg log messages # + from __future__ import with_statement -import sys -import os, os.path -import time +import sys, os, os.path, wx, time, traceback +from orpg.orpgCore import component from orpg.external.terminalwriter import TerminalWriter from orpg.tools.decorators import pending_deprecation from orpg.dirpath import dir_struct @@ -43,6 +43,38 @@ ORPG_NOTE = 8 ORPG_DEBUG = 16 +def Crash(type, value, crash): + crash_report = open(dir_struct["home"] + 'crash-report.txt', "w") + traceback.print_exception(type, value, crash, file=crash_report) + crash_report.close() + msg = '' + crash_report = open(dir_struct["home"] + 'crash-report.txt', "r") + for line in crash_report: msg += line + logger.exception(msg) + crash_report.close() + logger.exception("Crash Report Created!!") + logger.info("Printed out a datafile called crash-report.txt\nPress to exit!", True); raw_input('') + exit() + +class DebugConsole(wx.Frame): + def __init__(self, parent): + super(DebugConsole, self).__init__(parent, -1, "Debug Window") + icon = None + icon = wx.Icon(dir_struct["icon"]+'note.ico', wx.BITMAP_TYPE_ICO) + self.SetIcon( icon ) + self.console = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE | wx.TE_READONLY) + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(self.console, 1, wx.EXPAND) + self.SetSizer(sizer) + self.SetAutoLayout(True) + self.SetSize((300, 175)) + self.Bind(wx.EVT_CLOSE, self.Min) + self.Min(None) + component.add('debugger', self.console) + + def Min(self, evt): + self.Hide() + class orpgLog(object): _log_level = 7 _log_name = None @@ -90,7 +122,8 @@ def log(self, msg, log_type, to_console=False): if self.log_to_console or to_console or log_type == ORPG_CRITICAL: self._io.line(str(msg), **self._lvl_args[log_type]['colorizer']) - + try: component.get('debugger').AppendText(".. " + str(msg) +'\n') + except: pass if log_type & self.log_level or to_console: atr = {'msg': msg, 'level': self._lvl_args[log_type]['log_string']} @@ -156,3 +189,4 @@ log_to_console = property(_get_log_to_console, _set_log_to_console) logger = orpgLog(dir_struct.get("user") + "runlogs/") +crash = sys.excepthook = Crash