<s> import sys <EOL> import os <EOL> import time <EOL> import stat <EOL> import datetime <EOL> from gluon . utils import md5_hash <EOL> from gluon . restricted import RestrictedError <EOL> from gluon . tools import Mail <EOL> path = os . path . join ( request . folder , '<STR_LIT>' ) <EOL> hashes = { } <EOL> mail = Mail ( ) <EOL> SLEEP_MINUTES = <NUM_LIT:5> <EOL> ALLOW_DUPLICATES = True <EOL> mail . settings . server = '<STR_LIT>' <EOL> mail . settings . sender = '<STR_LIT>' <EOL> administrator_email = '<STR_LIT>' <EOL> while <NUM_LIT:1> : <EOL> for file in os . listdir ( path ) : <EOL> if not ALLOW_DUPLICATES : <EOL> fileobj = open ( file , '<STR_LIT:r>' ) <EOL> try : <EOL> file_data = fileobj . read ( ) <EOL> finally : <EOL> fileobj . close ( ) <EOL> key = md5_hash ( file_data ) <EOL> if key in hashes : <EOL> continue <EOL> hashes [ key ] = <NUM_LIT:1> <EOL> error = RestrictedError ( ) <EOL> error . load ( request , request . application , file ) <EOL> mail . send ( to = administrator_email , <EOL> subject = '<STR_LIT>' , message = error . traceback ) <EOL> os . unlink ( os . path . join ( path , file ) ) <EOL> time . sleep ( SLEEP_MINUTES * <NUM_LIT> ) </s>
