# Path: pupa/exceptions.py
# class CommandError(PupaError):
#     """ Errors from within pupa CLI """


import os
import sys
import logging.config
import argparse
import importlib
import traceback
from django.conf import settings
from pupa.exceptions import CommandError
            logger.error('exception "%s" prevented loading of %s module', e, mod)

    # process args
    args, other = parser.parse_known_args()

    # set log level from command line
    handler_level = getattr(logging, args.loglevel.upper(), 'INFO')
    settings.LOGGING['handlers']['default']['level'] = handler_level
    logging.config.dictConfig(settings.LOGGING)

    # turn debug on
    if args.debug:
        try:
            debug_module = importlib.import_module('ipdb')
        except ImportError:
            debug_module = importlib.import_module('pdb')

        # turn on PDB-on-error mode
        # stolen from http://stackoverflow.com/questions/1237379/
        # if this causes problems in interactive mode check that page
        def _tb_info(type, value, tb):
            traceback.print_exception(type, value, tb)
            debug_module.pm()
        sys.excepthook = _tb_info

    if not args.subcommand:
        parser.print_help()
    else:
        try:
            subcommands[args.subcommand].handle(args, other)

# Path: pupa/exceptions.py
# class CommandError(PupaError):
#     """ Errors from within pupa CLI """


# Path: pupa/cli/__main__.py
import os
import sys
import logging.config
import argparse
import importlib
import traceback
from django.conf import settings
from pupa.exceptions import CommandError

            logger.error('exception "%s" prevented loading of %s module', e, mod)

    # process args
    args, other = parser.parse_known_args()

    # set log level from command line
    handler_level = getattr(logging, args.loglevel.upper(), 'INFO')
    settings.LOGGING['handlers']['default']['level'] = handler_level
    logging.config.dictConfig(settings.LOGGING)

    # turn debug on
    if args.debug:
        try:
            debug_module = importlib.import_module('ipdb')
        except ImportError:
            debug_module = importlib.import_module('pdb')

        # turn on PDB-on-error mode
        # stolen from http://stackoverflow.com/questions/1237379/
        # if this causes problems in interactive mode check that page
        def _tb_info(type, value, tb):
            traceback.print_exception(type, value, tb)
            debug_module.pm()
        sys.excepthook = _tb_info

    if not args.subcommand:
        parser.print_help()
    else:
        try:
            subcommands[args.subcommand].handle(args, other)

        except CommandError as e: