Ejemplo n.º 1
0
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.hq_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
Ejemplo n.º 2
0
def make_remote_profile(app, langs=None):
    try:
        profile = six.moves.urllib.request.urlopen(app.profile_url).read()
    except Exception:
        raise AppEditingError('Unable to access profile url: "%s"' %
                              app.profile_url)

    if app.manage_urls:
        profile_xml = ProfileXML(profile)

        if app.manage_urls:
            profile_xml.auto_set_versions(app.version)
            profile_xml.set_attribute('update', app.hq_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 = 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 langs:
                profile_xml.set_property("cur_locale", langs[0])

        profile = profile_xml.render()
    return profile
Ejemplo n.º 3
0
def get_mobile_worker_max_username_length(domain):
    """
    The auth_user table only allows for usernames up to 128 characters long.
    The code used to allow for usernames up to 80 characters, but that
    didn't properly take into consideration the fact that the domain and
    site name vary.
    """
    return min(128 - len(cc_user_domain(domain)) - 1, 80)
Ejemplo n.º 4
0
def get_mobile_worker_max_username_length(domain):
    """
    The auth_user table only allows for usernames up to 128 characters long.
    The code used to allow for usernames up to 80 characters, but that
    didn't properly take into consideration the fact that the domain and
    site name vary.
    """
    return min(128 - len(cc_user_domain(domain)) - 1, 80)