<s> import datetime <EOL> from optparse import make_option <EOL> from django . core . management . base import BaseCommand <EOL> from django . utils import timezone <EOL> from modoboa . core . models import Log <EOL> from modoboa . lib import parameters <EOL> class Command ( BaseCommand ) : <EOL> args = '<STR_LIT>' <EOL> help = '<STR_LIT>' <EOL> option_list = BaseCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = '<STR_LIT>' ) , <EOL> make_option ( '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = '<STR_LIT>' ) <EOL> ) <EOL> def __vprint ( self , msg ) : <EOL> if not self . verbose : <EOL> return <EOL> print msg <EOL> def handle ( self , * args , ** options ) : <EOL> if options [ "<STR_LIT>" ] : <EOL> import logging <EOL> l = logging . getLogger ( "<STR_LIT>" ) <EOL> l . setLevel ( logging . DEBUG ) <EOL> l . addHandler ( logging . StreamHandler ( ) ) <EOL> self . verbose = options [ "<STR_LIT>" ] <EOL> log_maximum_age = int ( parameters . get_admin ( "<STR_LIT>" ) ) <EOL> self . __vprint ( "<STR_LIT>" % log_maximum_age ) <EOL> limit = timezone . now ( ) - datetime . timedelta ( log_maximum_age ) <EOL> Log . objects . filter ( date_created__lt = limit ) . delete ( ) <EOL> self . __vprint ( "<STR_LIT>" ) </s>
