<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def discover_satellite(cli, deploy=True, timeout=5):
 """Looks to make sure a satellite exists, returns endpoint First makes sure we have dotcloud account credentials. Then it looks up the environment for the satellite app. This will contain host and port to construct an endpoint. However, if app doesn't exist, or endpoint does not check out, we call `launch_satellite` to deploy, which calls `discover_satellite` again when finished. Ultimately we return a working endpoint. If deploy is False it will not try to deploy. """

    if not cli.global_config.loaded:
        cli.die("Please setup skypipe by running `skypipe --setup`")

    try:
        endpoint = lookup_endpoint(cli)
        ok = client.check_skypipe_endpoint(endpoint, timeout)
        if ok:
            return endpoint
        else:
            return launch_satellite(cli) if deploy else None
    except (RESTAPIError, KeyError):
        return launch_satellite(cli) if deploy else None