# 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)
                    # If the --manual-end option was specified, we can now exit
                    self.status_update('The TestRun was successfully closed.')
                    return
            if options['manual_end']:
                # The --manual-end option was specified, but there was no
                # existing run to close.
                raise CommandError('There is no open TestRun to end.')

            filters['start'] = datetime.now()
            test_run = TestRun(**filters)

            if options['name']:
                test_run.name = options['name']
            if options['description']:
                test_run.description = options['description']

            test_run.save()

            if options['manual_start']:
                # The TestRun was successfully created
                self.status_update('A new TestRun was successfully opened.')
                return

        urls = []
        for url_list in url_lists:
            with open(url_list) as f:
                urls.extend([l.strip() for l in f.readlines()
                             if not l.startswith('#')])

        if options['sitemap']:

# 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)

                    # If the --manual-end option was specified, we can now exit
                    self.status_update('The TestRun was successfully closed.')
                    return
            if options['manual_end']:
                # The --manual-end option was specified, but there was no
                # existing run to close.
                raise CommandError('There is no open TestRun to end.')

            filters['start'] = datetime.now()
            test_run = TestRun(**filters)

            if options['name']:
                test_run.name = options['name']
            if options['description']:
                test_run.description = options['description']

            test_run.save()

            if options['manual_start']:
                # The TestRun was successfully created
                self.status_update('A new TestRun was successfully opened.')
                return

        urls = []
        for url_list in url_lists:
            with open(url_list) as f:
                urls.extend([l.strip() for l in f.readlines()
                             if not l.startswith('#')])

        if options['sitemap']:

            sitemaps = import_from_string(options['sitemap'])