<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_commands():
 """ Get all valid commands return - all valid commands in dictionary form """

    commands = {}

    #Try to load the settings file (settings can be specified on the command line) and get the INSTALLED_APPS
    try:
        from percept.conf.base import settings
        apps = settings.INSTALLED_APPS
    except KeyError:
        apps = []

    #For each app, try to find the command module (command folder in the app)
    #Then, try to load all commands in the directory
    for app_name in apps:
        try:
            path = find_commands_module(app_name)
            commands.update(dict([(name, app_name) for name in find_all_commands(path)]))
        except ImportError as e:
            pass

    return commands