<NME> cleanlogs.py
<BEF> # coding: utf-8

import datetime
from optparse import make_option

from django.core.management.base import BaseCommand
from django.utils import timezone
from modoboa.parameters import tools as param_tools


class Command(BaseCommand):


class Command(BaseCommand):
    args = ''
    help = 'Log table cleanup'

    option_list = BaseCommand.option_list + (
        make_option('--debug',
                    action='store_true',
                    default=False,
                    help='Activate debug output'),
        make_option('--verbose',
                    action='store_true',
                    default=False,
                    help='Display informational messages')
    )

    def __vprint(self, msg):
        if not self.verbose:

    def handle(self, *args, **options):

    def handle(self, *args, **options):
        if options["debug"]:
            import logging
            l = logging.getLogger("django.db.backends")
            l.setLevel(logging.DEBUG)
            l.addHandler(logging.StreamHandler())
        log_maximum_age = param_tools.get_global_parameter("log_maximum_age")
        self.__vprint("Deleting logs older than %d days..." % log_maximum_age)
        limit = timezone.now() - datetime.timedelta(log_maximum_age)
        Log.objects.filter(date_created__lt=limit).delete()
        self.__vprint("Done.")

<MSG> Update management commands.

see #1024

<DFF> @@ -1,7 +1,7 @@
 # coding: utf-8
 
 import datetime
-from optparse import make_option
+import logging
 
 from django.core.management.base import BaseCommand
 from django.utils import timezone
@@ -12,19 +12,17 @@ from ... import parameters
 
 
 class Command(BaseCommand):
-    args = ''
-    help = 'Log table cleanup'
-
-    option_list = BaseCommand.option_list + (
-        make_option('--debug',
-                    action='store_true',
-                    default=False,
-                    help='Activate debug output'),
-        make_option('--verbose',
-                    action='store_true',
-                    default=False,
-                    help='Display informational messages')
-    )
+    args = ""
+    help = "Log table cleanup"
+
+    def add_arguments(self, parser):
+        """Add extra arguments to command line."""
+        parser.add_argument(
+            "--debug", action="store_true", default=False,
+            help="Activate debug output")
+        parser.add_argument(
+            "--verbose", action="store_true", default=False,
+            help="Display informational messages")
 
     def __vprint(self, msg):
         if not self.verbose:
@@ -33,7 +31,6 @@ class Command(BaseCommand):
 
     def handle(self, *args, **options):
         if options["debug"]:
-            import logging
             l = logging.getLogger("django.db.backends")
             l.setLevel(logging.DEBUG)
             l.addHandler(logging.StreamHandler())

Update management commands.