def get_snapshot(exception, context=10):
 (etype, evalue, etb) = sys.exc_info()
 if isinstance(etype, types.ClassType):
  etype = etype.__name__
 s = {u'pyver': u'Python {version:s}: {executable:s} (prefix: {prefix:s})'.format(version=sys.version.split()[0], executable=sys.executable, prefix=sys.prefix), u'timestamp': cstr(datetime.datetime.now()), u'traceback': traceback.format_exc(), u'frames': [], u'etype': cstr(etype), u'evalue': cstr(`evalue`), u'exception': {}, u'locals': {}}
 records = inspect.getinnerframes(etb, 5)
 for (frame, file, lnum, func, lines, index) in records:
  file = ((file and os.path.abspath(file)) or u'?')
  (args, varargs, varkw, locals) = inspect.getargvalues(frame)
  call = u''
  if (func != u'?'):
   call = inspect.formatargvalues(args, varargs, varkw, locals, formatvalue=(lambda value: u'={}'.format(pydoc.text.repr(value))))
  f = {u'file': file, u'func': func, u'call': call, u'lines': {}, u'lnum': lnum}
  def reader(lnum=[lnum]):
   try:
    return linecache.getline(file, lnum[0])
   finally:
    lnum[0] += 1
  vars = cgitb.scanvars(reader, frame, locals)
  if (index is not None):
   i = (lnum - index)
   for line in lines:
    f[u'lines'][i] = line.rstrip()
    i += 1
  f[u'dump'] = {}
  for (name, where, value) in vars:
   if (name in f[u'dump']):
    continue
   if (value is not cgitb.__UNDEF__):
    if (where == u'global'):
     name = u'global {name:s}'.format(name=name)
    elif (where != u'local'):
     name = ((where + u' ') + name.split(u'.')[(-1)])
    f[u'dump'][name] = pydoc.text.repr(value)
   else:
    f[u'dump'][name] = u'undefined'
  s[u'frames'].append(f)
 if isinstance(evalue, BaseException):
  for name in dir(evalue):
   if (((name != u'messages') or (sys.version_info < 2.6)) and (not name.startswith(u'__'))):
    value = pydoc.text.repr(getattr(evalue, name))
    if ((type(value) == str) and value.startswith("u'")):
     value = eval(value)
    s[u'exception'][name] = encode(value)
 for (name, value) in locals.items():
  if ((type(value) == str) and value.startswith("u'")):
   value = eval(value)
  s[u'locals'][name] = pydoc.text.repr(value)
 return s

def get_snapshot ( exception , context = 10 ) : ( etype , evalue , etb ) = sys . exc_info ( ) if isinstance ( etype , types . ClassType ) : etype = etype . __name__ s = { u'pyver' : u'Python {version:s}: {executable:s} (prefix: {prefix:s})' . format ( version = sys . version . split ( ) [ 0 ] , executable = sys . executable , prefix = sys . prefix ) , u'timestamp' : cstr ( datetime . datetime . now ( ) ) , u'traceback' : traceback . format_exc ( ) , u'frames' : [ ] , u'etype' : cstr ( etype ) , u'evalue' : cstr ( ` evalue ` ) , u'exception' : { } , u'locals' : { } } records = inspect . getinnerframes ( etb , 5 ) for ( frame , file , lnum , func , lines , index ) in records : file = ( ( file and os . path . abspath ( file ) ) or u'?' ) ( args , varargs , varkw , locals ) = inspect . getargvalues ( frame ) call = u'' if ( func != u'?' ) : call = inspect . formatargvalues ( args , varargs , varkw , locals , formatvalue = ( lambda value : u'={}' . format ( pydoc . text . repr ( value ) ) ) ) f = { u'file' : file , u'func' : func , u'call' : call , u'lines' : { } , u'lnum' : lnum } def reader ( lnum = [ lnum ] ) : try : return linecache . getline ( file , lnum [ 0 ] ) finally : lnum [ 0 ] += 1 vars = cgitb . scanvars ( reader , frame , locals ) if ( index is not None ) : i = ( lnum - index ) for line in lines : f [ u'lines' ] [ i ] = line . rstrip ( ) i += 1 f [ u'dump' ] = { } for ( name , where , value ) in vars : if ( name in f [ u'dump' ] ) : continue if ( value is not cgitb . __UNDEF__ ) : if ( where == u'global' ) : name = u'global {name:s}' . format ( name = name ) elif ( where != u'local' ) : name = ( ( where + u' ' ) + name . split ( u'.' ) [ ( - 1 ) ] ) f [ u'dump' ] [ name ] = pydoc . text . repr ( value ) else : f [ u'dump' ] [ name ] = u'undefined' s [ u'frames' ] . append ( f ) if isinstance ( evalue , BaseException ) : for name in dir ( evalue ) : if ( ( ( name != u'messages' ) or ( sys . version_info < 2.6 ) ) and ( not name . startswith ( u'__' ) ) ) : value = pydoc . text . repr ( getattr ( evalue , name ) ) if ( ( type ( value ) == str ) and value . startswith ( "u'" ) ) : value = eval ( value ) s [ u'exception' ] [ name ] = encode ( value ) for ( name , value ) in locals . items ( ) : if ( ( type ( value ) == str ) and value . startswith ( "u'" ) ) : value = eval ( value ) s [ u'locals' ] [ name ] = pydoc . text . repr ( value ) return s
get detailed information about a given snapshot cli example: .