Python django.core.management.base.BaseCommand() Examples

The following are code examples for showing how to use django.core.management.base.BaseCommand(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: USTC-Software-2017   Author: igemsoftware2017   File: biohub-cli.py    (license) View Source Project 6 votes vote down vote up
def fetch_command(self, subcommand, command_sets=None):
        """
        Tries to fetch the given subcommand. If it can't be found, prints a
        message with the appropriate command called from the command line
        (e.g. "biohub_cli").
        """

        # Check if the subcommand is available
        try:
            app_name = self.available_commands[subcommand]
        except KeyError:
            sys.stderr.write(
                "Unknown command: %r\nType '%s --help' for usage.\n"
                % (subcommand, self.prog_name))
            sys.exit(1)

        if isinstance(app_name, BaseCommand):
            klass = app_name
        else:
            klass = load_command_class(app_name, subcommand)

        return klass