def make_remote_profile(app):
    try:
        profile = urllib2.urlopen(app.profile_url).read()
    except Exception:
        raise AppEditingError('Unable to access profile url: "%s"' % app.profile_url)

    if app.manage_urls or app.build_langs:
        profile_xml = ProfileXML(profile)

        if app.manage_urls:
            profile_xml.auto_set_versions(app.version)
            profile_xml.set_attribute('update', app.profile_url)
            profile_xml.set_property("ota-restore-url", app.ota_restore_url)
            profile_xml.set_property("PostURL", app.post_url)
            profile_xml.set_property("cc_user_domain", cc_user_domain(app.domain))
            profile_xml.set_property('form-record-url', app.form_record_url)
            profile_xml.set_property('key_server', app.key_server_url)
            download_index_url = urlresolvers.reverse(
                'download_index',
                args=[app.domain, app.get_id],
            )
            for suite_node in profile_xml.findall('suite'):
                reset_suite_remote_url(
                    suite_node=suite_node,
                    profile_url=app.profile_url,
                    url_base=app.url_base,
                    download_index_url=download_index_url
                )

        if app.build_langs:
            profile_xml.set_property("cur_locale", app.build_langs[0])

        profile = profile_xml.render()
    return profile
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/app_manager/remote_app.py/make_remote_profile/original