def find_commands_module(app_name):
    """
    Find the commands module in each app (if it exists) and return the path
    app_name : The name of an app in the INSTALLED_APPS setting
    return - path to the app
    """
    parts = app_name.split('.')
    parts.append('commands')
    parts.reverse()
    part = parts.pop()
    path = None

    #Load the module if needed
    try:
        f, path, descr = imp.find_module(part, path)
    except __HOLE__ as e:
        if os.path.basename(os.getcwd()) != part:
            raise e
        else:
            try:
                if f:
                    f.close()
            except UnboundLocalError:
                log.error("Could not import module {0} at path {1}.  Sys.path is {2}".format(part, path, sys.path))

    #Go down level by and level and try to load the module at each level
    while parts:
        part = parts.pop()
        f, path, descr = imp.find_module(part, [path] if path else None)
        if f:
            f.close()
    return path
dataset/ETHPy150Open VikParuchuri/percept/percept/management/base.py/find_commands_module