def find_commands_module(app_name):
    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 ImportError 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
Find the commands module in each app (if it exists) and return the path
dataset/ETHPy150Open VikParuchuri/percept/percept/management/base.py/find_commands_module