annotate orpg/tools/orpg_log.py @ 123:174658f839c0 alpha

Traipse Alpha 'OpenRPG' {091001-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (Completed, see documentation for usage) Mercurial's hgweb folder is ported to upmana Happy Halloween!
author sirebral
date Sun, 01 Nov 2009 01:12:50 -0600
parents 36919b8a3ef9
children 8827271fbe1b
rev   line source
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3 # openrpg-dev@lists.sourceforge.net
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # (at your option) any later version.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 # GNU General Public License for more details.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 # --
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 # File: orpg_log.py
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 # Author: Dj Gilcrease
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22 # Maintainer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 # Version:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
24 # $Id: orpg_log.py,v 1.9 2007/05/06 16:43:02 digitalxero Exp $
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
26 # Description: classes for orpg log messages
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 #
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
28
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
29 from __future__ import with_statement
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
30 import sys, os, os.path, wx, time, traceback, inspect
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
32 from orpg.orpgCore import component
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
33 from orpg.external.terminalwriter import TerminalWriter
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
34 from orpg.tools.decorators import pending_deprecation
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
35 from orpg.dirpath import dir_struct
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
36
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
37 #########################
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
38 ## Error Types
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
39 #########################
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
40 ORPG_PRINT = 0
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
41 ORPG_CRITICAL = 1
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
42 ORPG_GENERAL = 2
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
43 ORPG_INFO = 4
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
44 ORPG_NOTE = 8
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
45 ORPG_DEBUG = 16
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
47
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
48 def Crash(type, value, crash):
dd4be4817377 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.
sirebral
parents: 66
diff changeset
49 crash_report = open(dir_struct["home"] + 'crash-report.txt', "w")
dd4be4817377 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.
sirebral
parents: 66
diff changeset
50 traceback.print_exception(type, value, crash, file=crash_report)
dd4be4817377 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.
sirebral
parents: 66
diff changeset
51 crash_report.close()
dd4be4817377 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.
sirebral
parents: 66
diff changeset
52 msg = ''
dd4be4817377 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.
sirebral
parents: 66
diff changeset
53 crash_report = open(dir_struct["home"] + 'crash-report.txt', "r")
dd4be4817377 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.
sirebral
parents: 66
diff changeset
54 for line in crash_report: msg += line
dd4be4817377 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.
sirebral
parents: 66
diff changeset
55 logger.exception(msg)
dd4be4817377 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.
sirebral
parents: 66
diff changeset
56 crash_report.close()
dd4be4817377 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.
sirebral
parents: 66
diff changeset
57 logger.exception("Crash Report Created!!")
81
65c212e9a5b4 Controls panel is completed. Users cannot delete branches nicely without a Merc upgrade, so that feature will appear in Pious Paladin. Crash report is being tested on windows.
sirebral
parents: 79
diff changeset
58 logger.info("Printed out crash-report.txt in your System folder", True)
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
59
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
60 class Term2Win(object):
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
61 # A stdout redirector. Allows the messages from Mercurial to be seen in the Install Window
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
62 def write(self, text):
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
63 #logger.stdout(text)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
64 wx.Yield()
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
65 #sys.__stdout__.write(text)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
66
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
67 class TrueDebug(object):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
68 ### Alpha ###
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
69 """A simple debugger. Add debug() to a function and it prints the function name and any objects included.
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
70 Adding True to locale prints the file name where the function is. Adding False to log turns the log off.
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
71 This feature can be modified to trace deeper and find the bugs faster, ending the puzzle box."""
123
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
72 def __init__(self, objects=None, locale=False, log=True, parents=False):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
73 if log == False: return
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
74 current = inspect.currentframe()
123
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
75 if parents: self.get_parents(current)
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
76 self.true_debug(current, objects, locale)
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
77
123
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
78 def true_debug(self, current, objects, locale):
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
79 debug_string = 'Function: ' + str(inspect.getouterframes(current)[1][3])
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
80 #if locale == 'all': print inspect.getouterframes(current)[4]; return
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
81 if objects != None: debug_string += ' Objects: ' + str(objects)
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
82 if locale: debug_string += ' File: ' + str(inspect.getouterframes(current)[1][1])
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
83 print debug_string
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
84 return
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
85
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
86 def get_parents(self, current):
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
87 debug_string = 'Function: ' + str(inspect.getouterframes(current)[1][3]) + ' Parents:'
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
88 family = list(inspect.getouterframes(current))
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
89 for parent in family:
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
90 debug_string += ' ' + str(parent[4])
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
91 print debug_string
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
92 return
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
93
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
94 class DebugConsole(wx.Frame):
dd4be4817377 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.
sirebral
parents: 66
diff changeset
95 def __init__(self, parent):
95
af6bf998f425 Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 86
diff changeset
96 super(DebugConsole, self).__init__(parent, -1, "Debug Console")
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
97 icon = wx.Icon(dir_struct["icon"]+'note.ico', wx.BITMAP_TYPE_ICO)
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
98 self.SetIcon(icon)
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
99 self.console = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE | wx.TE_READONLY)
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
100 self.bt_clear = wx.Button(self, wx.ID_CLEAR)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
101 self.report = wx.Button(self, wx.ID_ANY, 'Bug Report')
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
102 sizer = wx.GridBagSizer(hgap=1, vgap=1)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
103 sizer.Add(self.console, (0,0), span=(1,2), flag=wx.EXPAND)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
104 sizer.Add(self.bt_clear, (1,0), flag=wx.ALIGN_LEFT)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
105 sizer.Add(self.report, (1,1), flag=wx.ALIGN_LEFT)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
106 sizer.AddGrowableCol(0)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
107 sizer.AddGrowableRow(0)
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
108 self.SetSizer(sizer)
dd4be4817377 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.
sirebral
parents: 66
diff changeset
109 self.SetAutoLayout(True)
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
110 self.SetSize((450, 175))
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
111 self.Bind(wx.EVT_CLOSE, self.Min)
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
112 self.Bind(wx.EVT_BUTTON, self.clear, self.bt_clear)
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
113 self.Bind(wx.EVT_BUTTON, self.bug_report, self.report)
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
114 self.Min(None)
123
174658f839c0 Traipse Alpha 'OpenRPG' {091001-00}
sirebral
parents: 122
diff changeset
115 #sys.stdout = Term2Win()
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
116 component.add('debugger', self.console)
dd4be4817377 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.
sirebral
parents: 66
diff changeset
117
dd4be4817377 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.
sirebral
parents: 66
diff changeset
118 def Min(self, evt):
dd4be4817377 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.
sirebral
parents: 66
diff changeset
119 self.Hide()
dd4be4817377 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.
sirebral
parents: 66
diff changeset
120
121
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
121 def clear(self, evt):
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
122 self.console.SetValue('')
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
123
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
124 def bug_report(self, evt):
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
125 pass
496dbf12a6cb Traipse Alpha 'OpenRPG' {091030-00}
sirebral
parents: 95
diff changeset
126
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
127 class orpgLog(object):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
128 _log_level = 7
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
129 _log_name = None
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
130 _log_to_console = False
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
131 _io = TerminalWriter(sys.stderr)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
132 _lvl_args = None
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
133
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
134 def __new__(cls, *args, **kwargs):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
135 it = cls.__dict__.get("__it__")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
136 if it is not None:
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
137 return it
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
138 cls.__it__ = it = object.__new__(cls)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
139 return it
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
140
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
141 def __init__(self, home_dir, filename='orpgRunLog '):
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
142 self._lvl_args = {16: {'colorizer': {'green': True},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
143 'log_string': 'DEBUG'},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
144 8: {'colorizer': {'bold': True, 'green':True},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
145 'log_string':'NOTE'},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
146 4: {'colorizer': {'blue': True},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
147 'log_string': 'INFO'},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
148 2: {'colorizer': {'red': True},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
149 'log_string': 'ERROR'},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
150 1: {'colorizer': {'bold': True, 'red': True},
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
151 'log_string': 'EXCEPTION'}}
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
152 if not self.log_name:
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
153 self.log_name = home_dir + filename + time.strftime('%m-%d-%Y.txt',
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
154 time.localtime(time.time()))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
155
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
156 def debug(self, msg, to_console=False):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
157 self.log(msg, ORPG_DEBUG, to_console)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
158
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
159 def note(self, msg, to_console=False):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
160 self.log(msg, ORPG_NOTE, to_console)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
161
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
162 def info(self, msg, to_console=False):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
163 self.log(msg, ORPG_INFO, to_console)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
164
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
165 def general(self, msg, to_console=False):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
166 self.log(msg, ORPG_GENERAL, to_console)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
167
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
168 def exception(self, msg, to_console=True):
95
af6bf998f425 Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 86
diff changeset
169 ### Beta ### Every 'Critical' exception will draw attention to the Debug Console
af6bf998f425 Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 86
diff changeset
170 component.get('frame').TraipseSuiteWarn('debug')
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
171 self.log(msg, ORPG_CRITICAL, to_console)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
172
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
173 def log(self, msg, log_type, to_console=False):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
174 if self.log_to_console or to_console or log_type == ORPG_CRITICAL:
82
2fa8bd6785a5 TerminalWriter's colors are nice, but if no debug console is open it causes the software to look for one until a recursion error is created. Crash reports are sent to the debug console and a pop-up tells the user one has happened. Fix to chat window from SnowDog.
sirebral
parents: 81
diff changeset
175 try: self._io.line(str(msg), **self._lvl_args[log_type]['colorizer'])
2fa8bd6785a5 TerminalWriter's colors are nice, but if no debug console is open it causes the software to look for one until a recursion error is created. Crash reports are sent to the debug console and a pop-up tells the user one has happened. Fix to chat window from SnowDog.
sirebral
parents: 81
diff changeset
176 except: pass #Fails without the Debug Console
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
177 try: component.get('debugger').AppendText(".. " + str(msg) +'\n')
dd4be4817377 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.
sirebral
parents: 66
diff changeset
178 except: pass
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
179
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
180 if log_type & self.log_level or to_console:
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
181 atr = {'msg': msg, 'level': self._lvl_args[log_type]['log_string']}
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
182 atr['time'] = time.strftime('[%x %X]', time.localtime(time.time()))
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
183 logMsg = '%(time)s (%(level)s) - %(msg)s\n' % (atr)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
184
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
185 with open(self.log_name, 'a') as f:
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
186 f.write(logMsg)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
187
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
188 @pending_deprecation("use logger.log_level = #")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
189 def setLogLevel(self, log_level):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
190 self.log_level = log_level
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
191
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
192 @pending_deprecation("use logger.log_level")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
193 def getLogLevel(self):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
194 return self.log_level
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
195
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
196 @pending_deprecation("use logger.log_name = bla")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
197 def setLogName(self, log_name):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
198 self.log_name = log_name
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
199
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
200 @pending_deprecation("use logger.log_name")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
201 def getLogName(self):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
202 return self.log_name
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
203
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
204 @pending_deprecation("use logger.log_to_console = True/False")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
205 def setLogToConsol(self, true_or_false):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
206 self.log_to_consol = true_or_false
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
207
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
208 @pending_deprecation("use logger.log_to_console")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
209 def getLogToConsol(self):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
210 return self.log_to_consol
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
211
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
212 """
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
213 Property Methods
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
214 """
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
215 def _get_log_level(self):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
216 return self._log_level
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
217 def _set_log_level(self, log_level):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
218 if not isinstance(log_level, int) or log_level < 1 or log_level > 31:
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
219 raise TypeError("The loggers level must be an int between 1 and 31")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
220
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
221 self._log_level = log_level
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
222
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
223 def _get_log_name(self):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
224 return self._log_name
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
225 def _set_log_name(self, name):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
226 if not os.access(os.path.abspath(os.path.dirname(name)), os.W_OK):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
227 raise IOError("Could not write to the specified location")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
228
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
229 self._log_name = name
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
230
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
231 def _get_log_to_console(self):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
232 return self._log_to_console
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
233 def _set_log_to_console(self, true_or_false):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
234 if not isinstance(true_or_false, bool):
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
235 raise TypeError("log_to_console must be a boolean value")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
236
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
237 self._log_to_console = true_or_false
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
238
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
239 log_level = property(_get_log_level, _set_log_level)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
240 log_name = property(_get_log_name, _set_log_name)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
241 log_to_console = property(_get_log_to_console, _set_log_to_console)
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
242
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 15
diff changeset
243 logger = orpgLog(dir_struct.get("user") + "runlogs/")
79
dd4be4817377 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.
sirebral
parents: 66
diff changeset
244 crash = sys.excepthook = Crash
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 121
diff changeset
245 debug = TrueDebug