Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Hook Class Reference

Public Member Functions

def __init__
 
def __call__
 
def handle
 

Data Fields

 display
 
 logdir
 
 context
 
 file
 

Detailed Description

A hook to replace sys.excepthook that shows tracebacks in HTML.

Definition at line 151 of file cgitb.py.

Constructor & Destructor Documentation

def __init__ (   self,
  display = 1,
  logdir = None,
  context = 5,
  file = None 
)

Definition at line 154 of file cgitb.py.

155  def __init__(self, display=1, logdir=None, context=5, file=None):
156  self.display = display # send tracebacks to browser if true
157  self.logdir = logdir # log tracebacks to files if not None
158  self.context = context # number of source code lines per frame
159  self.file = file or sys.stdout # place to send the output

Member Function Documentation

def __call__ (   self,
  etype,
  evalue,
  etb 
)

Definition at line 160 of file cgitb.py.

References Hook.handle(), and BaseHTTPRequestHandler.handle().

161  def __call__(self, etype, evalue, etb):
162  self.handle((etype, evalue, etb))
def handle (   self,
  info = None 
)

Definition at line 163 of file cgitb.py.

References Hook.context, Hook.display, traceback.format_exception(), cgitb.html(), dospath.join(), Hook.logdir, tempfile.mktemp(), aifc.open(), pydoc.replace(), and cgitb.reset().

164  def handle(self, info=None):
165  info = info or sys.exc_info()
166  self.file.write(reset())
167 
168  try:
169  text, doc = 0, html(info, self.context)
170  except: # just in case something goes wrong
171  import traceback
172  text, doc = 1, ''.join(traceback.format_exception(*info))
173 
174  if self.display:
175  if text:
176  doc = doc.replace('&', '&amp;').replace('<', '&lt;')
177  self.file.write('<pre>' + doc + '</pre>\n')
178  else:
179  self.file.write(doc + '\n')
180  else:
181  self.file.write('<p>A problem occurred in a Python script.\n')
182 
183  if self.logdir is not None:
184  import os, tempfile
185  name = tempfile.mktemp(['.html', '.txt'][text])
186  path = os.path.join(self.logdir, os.path.basename(name))
187  try:
188  file = open(path, 'w')
189  file.write(doc)
190  file.close()
191  msg = '<p> %s contains the description of this error.' % path
192  except:
193  msg = '<p> Tried to save traceback to %s, but failed.' % path
194  self.file.write(msg + '\n')
195  try:
196  self.file.flush()
197  except: pass

Field Documentation

context

Definition at line 157 of file cgitb.py.

display

Definition at line 155 of file cgitb.py.

file

Definition at line 158 of file cgitb.py.

logdir

Definition at line 156 of file cgitb.py.


The documentation for this class was generated from the following file: