Beispiel #1
0
def is_up_to_date():
    """
    Primitive update check. Checks local hash against GitHub hash for branch.
    Returns True if the player is up to date.
    """

    latest_sha, retrieved_update = fetch_remote_hash()
    git_branch = get_git_branch()
    git_hash = get_git_hash()
    git_short_hash = get_git_short_hash()
    get_device_id = r.get('device_id')

    if not latest_sha:
        logging.error('Unable to get latest version from GitHub')
        return True

    if not get_device_id:
        device_id = ''.join(
            random.choice(string.ascii_lowercase + string.digits)
            for _ in range(15))
        r.set('device_id', device_id)
    else:
        device_id = get_device_id

    if retrieved_update:
        if not settings['analytics_opt_out'] and not is_ci():
            mp = Mixpanel('d18d9143e39ffdb2a4ee9dcc5ed16c56')
            try:
                mp.track(
                    device_id, 'Version', {
                        'Branch':
                        str(git_branch),
                        'Hash':
                        str(git_short_hash),
                        'NOOBS':
                        os.path.isfile('/boot/os_config.json'),
                        'Balena':
                        is_balena_app(),
                        'Docker':
                        is_docker(),
                        'Pi_Version':
                        lookup_raspberry_pi_revision(
                            parse_cpu_info()['revision'])['model']
                    })
            except MixpanelException:
                pass
            except AttributeError:
                pass

    return latest_sha == git_hash
def get_raspberry_manufacturer(raspberry_pi_revision):
    """
    Quick DRY workaround. Needs to be refactored later.
    """
    return raspberry_pi_helper.lookup_raspberry_pi_revision(
        raspberry_pi_revision)['manufacturer']