Пример #1
0
def fetch_app_data(app_data, app_name):
    # Get Git URL, fail build if git_url is not found or wrong
    if 'git_url' in app_data:
        hosted_on = get_hosted_on(app_data['git_url'])
    else:
        raise exc.MissingGit(f"No 'git_url' key for {app_name!r} in apps.json")

    # Get metadata.json from the project;
    # fail build if meta_url is not found or wrong
    if 'meta_url' in app_data:
        meta_info = get_meta_info(app_data['meta_url'])
    else:
        raise exc.MissingMetadata(
            f"No 'meta_url' key for {app_name!r} in apps.json")

    # Check if categories are specified, warn if not
    if 'categories' not in app_data:
        print("  >> WARNING: No categories specified.")

    app_data['metainfo'] = complete_meta_info(app_name, meta_info,
                                              app_data['git_url'])
    app_data['gitinfo'] = get_git_branches(app_data['git_url'])
    app_data['hosted_on'] = hosted_on

    # Get logo URL, if it has been specified
    if 'logo' in app_data['metainfo']:
        app_data['logo'] = get_logo_url(app_data['metainfo']['logo'],
                                        app_data['meta_url'])

    return app_data
Пример #2
0
def get_hosted_on(url):
    try:
        urlopen(url, timeout=TIMEOUT_SECONDS)
    except Exception:
        raise exc.MissingGit("Value for 'git_url' in apps.json may be wrong: '{}'".format(url))

    netloc = urlparse(url).netloc

    # Remove port (if any)
    netloc = netloc.partition(':')[0]

    # Remove subdomains (this only works for domain suffixes of length 1!)
    # TODO: fix it for domains like yyy.co.uk
    netloc = ".".join(netloc.split('.')[-2:])

    return netloc
Пример #3
0
    print("[apps]")
    for app_name in sorted(apps_raw_data.keys()):
        print("  - {}".format(app_name))
        app_data = apps_raw_data[app_name]
        app_data['name'] = app_name

        html_app_fname = get_html_app_fname(app_name)
        subpage_name = os.path.join(html_subfolder_name,
                                    get_html_app_fname(app_name))
        subpage_abspath = os.path.join(outdir_abs, subpage_name)

        # Get Git URL, fail build if git_url is not found or wrong
        if 'git_url' in app_data:
            hosted_on = get_hosted_on(app_data['git_url'])
        else:
            raise exc.MissingGit(
                "No 'git_url' key for '{}' in apps.json".format(app_name))

        # Get metadata.json from the project;
        # fail build if meta_url is not found or wrong
        if 'meta_url' in app_data:
            meta_info = get_meta_info(app_data['meta_url'])
        else:
            raise exc.MissingMetadata(
                "No 'meta_url' key for '{}' in apps.json".format(app_name))

        # Check if categories are specified, warn if not
        if 'categories' not in app_data:
            print("  >> WARNING: No categories specified.")
        # Check correct categories are specified
        else:
            validate_categories(app_data['categories'], all_data['categories'])