<NME> cleanlogs.py
<BEF> import datetime
import logging

from optparse import make_option
from django.core.management.base import BaseCommand
from django.utils import timezone
from modoboa.core import load_settings
from modoboa.core.models import Log
from modoboa.lib import parameters

class Command(BaseCommand):
    """Command class."""

    help = "Log table cleanup"  # NOQA:A003

    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:
            return
        print(msg)

    def handle(self, *args, **options):
        if options["debug"]:
            log = logging.getLogger("django.db.backends")
            log.setLevel(logging.DEBUG)
            log.addHandler(logging.StreamHandler())
        self.verbose = options["verbose"]

            l.addHandler(logging.StreamHandler())
        self.verbose = options["verbose"]

        load_settings()
        log_maximum_age = int(parameters.get_admin("LOG_MAXIMUM_AGE"))
        self.__vprint("Deleting logs older than %d days..." % log_maximum_age)
        limit = timezone.now() - datetime.timedelta(log_maximum_age)

<MSG> Merge pull request #512 from carragom/master

Fix cleanlogs command.
<DFF> @@ -4,7 +4,7 @@ import datetime
 from optparse import make_option
 from django.core.management.base import BaseCommand
 from django.utils import timezone
-from modoboa.core import load_settings
+from modoboa.core import load_core_settings
 from modoboa.core.models import Log
 from modoboa.lib import parameters
 
@@ -37,7 +37,7 @@ class Command(BaseCommand):
             l.addHandler(logging.StreamHandler())
         self.verbose = options["verbose"]
 
-        load_settings()
+        load_core_settings()
         log_maximum_age = int(parameters.get_admin("LOG_MAXIMUM_AGE"))
         self.__vprint("Deleting logs older than %d days..." % log_maximum_age)
         limit = timezone.now() - datetime.timedelta(log_maximum_age)

Merge pull request #512 from carragom/master