# Path: debug_logging/settings.py
# LOGGING_CONFIG = _get_logging_config()
# 
# Path: debug_logging/handlers.py
# class DBHandler(logging.Handler):
#     
#     def emit(self, record):
#         if type(record.msg) is dict:
#             # Pull the project name, hostname, and revision out of the record
#             filters = {}
#             for key in ('project_name', 'hostname', 'revision'):
#                 if record.msg.has_key(key):
#                     filters[key] = record.msg.pop(key)
#             
#             # Find the open test run for this project
#             try:
#                 test_run = TestRun.objects.get(end__isnull=True, **filters)
#             except TestRun.DoesNotExist:
#                 # Don't log this request if there isn't an open TestRun
#                 return
#             record.msg['test_run'] = test_run
#             
#             instance = DebugLogRecord(**record.msg)
#             instance.save()
# 
# Path: debug_logging/utils.py
# def import_from_string(path):
#     i = path.rfind('.')
#     module, attr = path[:i], path[i + 1:]
#     try:
#         mod = import_module(module)
#     except ImportError, e:
#         raise ImproperlyConfigured(
#             'Error importing module %s: "%s"' % (module, e)
#         )
#     try:
#         instance = getattr(mod, attr)
#     except AttributeError:
#         raise ImproperlyConfigured(
#             'Module "%s" does not define a "%s" attribute' % (module, attr)
#         )
#     return instance


import sys
from datetime import datetime
from optparse import  make_option
from django.test.client import Client
from django.core.management.base import BaseCommand, CommandError
from django.contrib.sitemaps import Sitemap
from debug_logging.settings import LOGGING_CONFIG
from debug_logging.handlers import DBHandler
from debug_logging.utils import import_from_string
        from django.conf import settings
        from debug_logging.models import TestRun
        from debug_logging.utils import (get_project_name, get_hostname,
                                         get_revision)
        make_option('-u', '--username',
            action='store',
            dest='username',
            metavar='USERNAME',
            help='Run the test authenticated with the USERNAME provided.'
        ),
        make_option('-p', '--password',
            action='store',
            dest='password',
            metavar='PASSWORD',
            help='Run the test authenticated with the PASSWORD provided.'
        ),
    )

    def status_update(self, msg):
        if not self.quiet:
            print msg

    def status_ticker(self):
        if not self.quiet:
            sys.stdout.write('.')
            sys.stdout.flush()

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

        verbosity = int(options.get('verbosity', 1))
        self.quiet = verbosity < 1
        self.verbose = verbosity > 1

        # Dtermine if the DBHandler is used

# Path: debug_logging/settings.py
# LOGGING_CONFIG = _get_logging_config()
# 
# Path: debug_logging/handlers.py
# class DBHandler(logging.Handler):
#     
#     def emit(self, record):
#         if type(record.msg) is dict:
#             # Pull the project name, hostname, and revision out of the record
#             filters = {}
#             for key in ('project_name', 'hostname', 'revision'):
#                 if record.msg.has_key(key):
#                     filters[key] = record.msg.pop(key)
#             
#             # Find the open test run for this project
#             try:
#                 test_run = TestRun.objects.get(end__isnull=True, **filters)
#             except TestRun.DoesNotExist:
#                 # Don't log this request if there isn't an open TestRun
#                 return
#             record.msg['test_run'] = test_run
#             
#             instance = DebugLogRecord(**record.msg)
#             instance.save()
# 
# Path: debug_logging/utils.py
# def import_from_string(path):
#     i = path.rfind('.')
#     module, attr = path[:i], path[i + 1:]
#     try:
#         mod = import_module(module)
#     except ImportError, e:
#         raise ImproperlyConfigured(
#             'Error importing module %s: "%s"' % (module, e)
#         )
#     try:
#         instance = getattr(mod, attr)
#     except AttributeError:
#         raise ImproperlyConfigured(
#             'Module "%s" does not define a "%s" attribute' % (module, attr)
#         )
#     return instance


# Path: debug_logging/management/commands/log_urls.py
import sys
from datetime import datetime
from optparse import  make_option
from django.test.client import Client
from django.core.management.base import BaseCommand, CommandError
from django.contrib.sitemaps import Sitemap
from debug_logging.settings import LOGGING_CONFIG
from debug_logging.handlers import DBHandler
from debug_logging.utils import import_from_string
        from django.conf import settings
        from debug_logging.models import TestRun
        from debug_logging.utils import (get_project_name, get_hostname,
                                         get_revision)

        make_option('-u', '--username',
            action='store',
            dest='username',
            metavar='USERNAME',
            help='Run the test authenticated with the USERNAME provided.'
        ),
        make_option('-p', '--password',
            action='store',
            dest='password',
            metavar='PASSWORD',
            help='Run the test authenticated with the PASSWORD provided.'
        ),
    )

    def status_update(self, msg):
        if not self.quiet:
            print msg

    def status_ticker(self):
        if not self.quiet:
            sys.stdout.write('.')
            sys.stdout.flush()

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

        verbosity = int(options.get('verbosity', 1))
        self.quiet = verbosity < 1
        self.verbose = verbosity > 1

        # Dtermine if the DBHandler is used

        if True in [isinstance(handler, DBHandler) for handler in