<commit_before>from __future__ import print_function

import datetime
import sys

from django.apps import apps
from django.utils import six
from django.utils.encoding import get_system_encoding

from djgunicorn.gunicorn import run


# Use staticfiles's command by default, but fall back to default if it is
# not installed.
if apps.is_installed('django.contrib.staticfiles'):
    from django.contrib.staticfiles.management.commands.runserver import (
        Command as BaseCommand,
    )
else:
    from django.core.management.commands.runserver import (
        Command as BaseCommand,
    )


class Command(BaseCommand):

    help = "Starts a lightweight Web server for development with Gunicorn."

    def get_version(self):
        import djgunicorn
        return djgunicorn.__version__

    def run(self, **options):
        """Override runserver's entry point to bring Gunicorn on.

        A large portion of code in this method is copied from
        `django.core.management.commands.runserver`.
        """
        shutdown_message = options.get('shutdown_message', '')

        self.stdout.write("Performing system checks...\n\n")
        self.check(display_num_errors=True)
        self.check_migrations()
        now = datetime.datetime.now().strftime(r'%B %d, %Y - %X')
        if six.PY2:
            now = now.decode(get_system_encoding())
        self.stdout.write(now)

        addr, port = self.addr, self.port<commit_msg>Use a cool way to lookup runserver dynamically<commit_after>from __future__ import print_function

import datetime
import importlib
import sys

from django.core.management import get_commands
from django.utils import six
from django.utils.encoding import get_system_encoding

from djgunicorn.gunicorn import run


# Use the active runserver command as base. This is generally provided by
# staticfiles, but can be django.core if it's not installed, or even something
# else if some third-party app overrides it.
def get_command_class(name):
    module = importlib.import_module('{app}.management.commands.{name}'.format(
        app=get_commands()[name], name=name,
    ))
    return module.Command

BaseCommand = get_command_class('runserver')


class Command(BaseCommand):

    help = "Starts a lightweight Web server for development with Gunicorn."

    def get_version(self):
        import djgunicorn
        return djgunicorn.__version__

    def run(self, **options):
        """Override runserver's entry point to bring Gunicorn on.

        A large portion of code in this method is copied from
        `django.core.management.commands.runserver`.
        """
        shutdown_message = options.get('shutdown_message', '')

        self.stdout.write("Performing system checks...\n\n")
        self.check(display_num_errors=True)
        self.check_migrations()
        now = datetime.datetime.now().strftime(r'%B %d, %Y - %X')
        if six.PY2:
            now = now.decode(get_system_encoding())
        self.stdout.write(now)

        addr, port = self.addr, self.port
{'fraction_non_alphanumeric': 0.09033752481800132, 'fraction_numerical': 0.0006618133686300463, 'mean_word_length': 3.198611111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1550217', 'n_tokens_mistral': 867, 'n_tokens_neox': 828, 'n_words': 251}