﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14952	New find_commands(management_dir) to support .pyc and .pyo	lgx@…	nobody	"In django/core/management/__init__.py:

{{{
def find_commands(management_dir):
    """"""
    Given a path to a management directory, returns a list of all the command
    names that are available.

    Returns an empty list if no commands are defined.
    """"""
    command_dir = os.path.join(management_dir, 'commands')
    try:
        return [f[:-3] for f in os.listdir(command_dir)
                if not f.startswith('_') and f.endswith('.py')]
    except OSError:
        return []
}}}

In our environment, We compile all .py to .pyc, and then remove all .py.
Then manage.py can't find our commands because find_commands only find .py.

Here is a modified version for find_command:

{{{
def find_commands(management_dir):
    """"""
    Given a path to a management directory, returns a list of all the command
    names that are available.

    Returns an empty list if no commands are defined.
    """"""
    command_dir = os.path.join(management_dir, 'commands')
    ret = {}
    try:
        filenames = os.listdir(command_dir)
        for filename in filenames:
            if filename.startswith('_'):
                continue

            if filename.endswith('.py'):
                modname = filename[:-3]
            elif filename.endswith('.pyc') or filename.endswith('.pyo'):
                modname = filename[:-4]
            else:
                modname = None

            if modname:
                ret[modname] = 1
    except OSError:
        pass

    return ret.keys()
}}}

"	Uncategorized	closed	Core (Other)	1.2	Normal	wontfix	find_commands	Nicola	Unreviewed	0	0	0	0	0	0
