#NEWLINE# @ app . task ( name = 'tasks.auto_delete_size_is_exceeded' , ignore_result = True ) #NEWLINE# def auto_delete_size_is_exceeded( ) : #NEWLINE# #INDENT# logger = logging . getLogger ( 'limitation' ) #NEWLINE# model_list = [ ( 'crash' , 'Crash' ) , ( 'feedback' , 'Feedback' ) ] #NEWLINE# for model in model_list : #NEWLINE# #INDENT# result = delete_size_is_exceeded ( * model ) #NEWLINE# if result . get ( 'count' , 0 ) : #NEWLINE# #INDENT# result [ 'size' ] /= ( 1024.0 * 1024 ) #NEWLINE# log_id = str ( uuid . uuid4 ( ) ) #NEWLINE# params = dict ( log_id = log_id ) #NEWLINE# splunk_url = get_splunk_url ( params ) #NEWLINE# splunk_filter = ( ( 'log_id=%s' % log_id ) if splunk_url else None ) #NEWLINE# raven_extra = dict ( id = log_id , splunk_url = params , splunk_filter = splunk_filter ) #NEWLINE# raven . captureMessage ( ( "[Limitation]Periodic task 'Size is exceeded' cleaned up %d %s, total size of cleaned space is %.2f Mb[%d]" % ( result [ 'count' ] , model [ 1 ] , result [ 'size' ] , time . time ( ) ) ) , data = dict ( level = 20 , logger = 'limitation' ) , extra = raven_extra ) #NEWLINE# extra = dict ( log_id = log_id , meta = True , count = result [ 'count' ] , size = result [ 'size' ] , model = model [ 1 ] , reason = 'size_is_exceeded' ) #NEWLINE# logger . info ( add_extra_to_log_message ( 'Automatic cleanup' , extra = extra ) ) #NEWLINE# for element in result [ 'elements' ] : #NEWLINE# #INDENT# element . update ( dict ( log_id = log_id ) ) #NEWLINE# logger . info ( add_extra_to_log_message ( 'Automatic cleanup element' , extra = element ) )