Package schrodinger :: Package infra :: Module exception_handler :: Class ExceptionRecorder
[hide private]
[frames] | no frames]

Class ExceptionRecorder

object --+
         |
        ExceptionRecorder

A top level exception handler that writes uncaught exceptions to a folder in .schrodinger. The user is informed of the error and told to contact customer service.

This handler can be activated by sys.excepthook = ExceptionRecorder() or by calling the enable_handler() convenience function.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__call__(self, etype, value, tb)
Write the specified exception to disk and print a helpful error message to the user.
 
_recordException(self, etype, value, tb)
Write the specified exception to disk and display a helpful error message to the user in the terminal and, if running maestro, in the gui
str
_getMessage(self, filepath, html=False)
Returns an message formatted either as plain text or html
tuple
_getExcepFile(self)
Return the file that the exception should be written to.
generator
_genFilename(self)
Generate potential output filenames to write the exception to
 
_createExcepDir(self)
Create the exceptions directory if it does not already exist.
 
_cleanupExcepDir(self)
If there are more than _MAX_EXCEP_FILES - 1 files in the exceptions directory, remove the oldest files.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
int _OPENFLAGS = 193
The flags used when opening a file.
str _EXCEPTIONS_DIR = u'/home/buildbot/.schrodinger/exceptions'
The directory where exceptions are stored
int _MAX_EXCEP_FILES = 40
The maximum number of files allowed in the exceptions directory.
  _MAX_EXCEP_PER_SECOND = 50
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__call__(self, etype, value, tb)
(Call operator)

 

Write the specified exception to disk and print a helpful error message to the user. If anything goes wrong while recording the exception, print both the original exception and the new error to stderr.

Parameters:
  • etype (type) - The exception type
  • value (BaseException) - The exception that was raised
  • tb (traceback) - The traceback that led to the exception

_recordException(self, etype, value, tb)

 

Write the specified exception to disk and display a helpful error message to the user in the terminal and, if running maestro, in the gui

Parameters:
  • etype (type) - The exception type
  • value (BaseException) - The exception that was raised
  • tb (traceback) - The traceback that led to the exception

_getMessage(self, filepath, html=False)

 

Returns an message formatted either as plain text or html

Parameters:
  • filepath (str) - The full path of the file containing the traceback
  • html (bool) - Whether to return the message formatted in html or plain text
Returns: str
A formatted message

_getExcepFile(self)

 

Return the file that the exception should be written to.

Returns: tuple
A tuple of
  • An open filehandle to write the exception to
  • The filename corresponding to the filehandle
Raises:
  • Exception - If the desired output file cannot be opened or if no acceptable filename can be found.

_genFilename(self)

 

Generate potential output filenames to write the exception to

Returns: generator
A generator that iterates through potential output filenames, where each filename is a fully qualified path.

_createExcepDir(self)

 

Create the exceptions directory if it does not already exist.

Raises:
  • Exception - If we cannot create the exceptions directory

Class Variable Details [hide private]

_OPENFLAGS

The flags used when opening a file. These flags are set to ensure that files are opened in a thread-safe manner.
Type:
int
Value:
193

_MAX_EXCEP_FILES

The maximum number of files allowed in the exceptions directory. Once this number of files is hit, the oldest files will be erased after recording the next exception.
Type:
int
Value:
40