def cleanup_deleted_sources(store_dir, c):
 for source_dir in os.listdir(store_dir):
  try:
   source = c.execute('SELECT * FROM sources WHERE filesystem_id=?', (source_dir,)).fetchone()
   if (not source):
    print "Deleting source with no db entry ('{}')...".format(source_dir)
    secure_unlink(os.path.join(store_dir, source_dir))
  except Exception as e:
   print '\n!!  Error occurred cleaning up deleted sources for source {}'.format(source_dir)
   print 'Source had {} submissions'.format(len(os.listdir(os.path.join(store_dir, source_dir))))
   print traceback.format_exc()

def cleanup_deleted_sources ( store_dir , c ) : for source_dir in os . listdir ( store_dir ) : try : source = c . execute ( 'SELECT * FROM sources WHERE filesystem_id=?' , ( source_dir , ) ) . fetchone ( ) if ( not source ) : print "Deleting source with no db entry ('{}')..." . format ( source_dir ) secure_unlink ( os . path . join ( store_dir , source_dir ) ) except Exception as e : print '\n!!  Error occurred cleaning up deleted sources for source {}' . format ( source_dir ) print 'Source had {} submissions' . format ( len ( os . listdir ( os . path . join ( store_dir , source_dir ) ) ) ) print traceback . format_exc ( )
in 0 .