def collect_error_snapshots():
 if frappe.conf.disable_error_snapshot:
  return
 try:
  path = get_error_snapshot_path()
  if (not os.path.exists(path)):
   return
  for fname in os.listdir(path):
   fullpath = os.path.join(path, fname)
   try:
    with open(fullpath, u'rb') as filedata:
     data = json.load(filedata)
   except ValueError:
    os.remove(fullpath)
    continue
   for field in [u'locals', u'exception', u'frames']:
    data[field] = frappe.as_json(data[field])
   doc = frappe.new_doc(u'Error Snapshot')
   doc.update(data)
   doc.save()
   frappe.db.commit()
   os.remove(fullpath)
  clear_old_snapshots()
 except Exception as e:
  make_error_snapshot(e)
  raise

def collect_error_snapshots ( ) : if frappe . conf . disable_error_snapshot : return try : path = get_error_snapshot_path ( ) if ( not os . path . exists ( path ) ) : return for fname in os . listdir ( path ) : fullpath = os . path . join ( path , fname ) try : with open ( fullpath , u'rb' ) as filedata : data = json . load ( filedata ) except ValueError : os . remove ( fullpath ) continue for field in [ u'locals' , u'exception' , u'frames' ] : data [ field ] = frappe . as_json ( data [ field ] ) doc = frappe . new_doc ( u'Error Snapshot' ) doc . update ( data ) doc . save ( ) frappe . db . commit ( ) os . remove ( fullpath ) clear_old_snapshots ( ) except Exception as e : make_error_snapshot ( e ) raise
scheduled task to collect error snapshots from files and push into error snapshot table .