From 175eb30f4b5e0d4211a29c1224dfd8dbded104e4 Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Thu, 6 Jul 2023 02:14:56 +0530 Subject: [PATCH] pixel: Handle googlesource 429s * We gotta do this better but for now let's just band-aid it Change-Id: I0d23c0813f0b8d7948907a3b0e0acd9917ee2a9c --- pixel/get-new-device-vars.py | 82 +++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/pixel/get-new-device-vars.py b/pixel/get-new-device-vars.py index 3a0a047..763e668 100755 --- a/pixel/get-new-device-vars.py +++ b/pixel/get-new-device-vars.py @@ -44,47 +44,61 @@ def handle_ota(html_id): def get_all_aosp_branches(branch_filter): all_branches = [] - for line in cmd.Git().ls_remote("--sort=v:refname", PLATFORM_BUILD_URL, branch_filter, tags=False, refs=True).split('\n'): - try: - (ref, branch) = line.split('\t') - except ValueError: - pass - all_branches.append(branch.replace("refs/heads/", "")) - return all_branches + try: + for line in cmd.Git().ls_remote("--sort=v:refname", PLATFORM_BUILD_URL, branch_filter, tags=False, refs=True).split('\n'): + try: + (ref, branch) = line.split('\t') + except ValueError: + pass + all_branches.append(branch.replace("refs/heads/", "")) + return all_branches + except Exception as e: + return all_branches def get_aosp_branch_for_build_id(aosp_branches, wanted_build_id): - for aosp_branch in aosp_branches: - output = base64.decodebytes(urllib.request.urlopen(BUILD_ID_URL.format("heads/" + aosp_branch)).read()).decode() - for line in output.split('\n'): - if BUILD_ID_FILTER in line: - found_build_id = line.split("=")[1] - if found_build_id == wanted_build_id: - print('new_aosp_branch="{0}"'.format(aosp_branch)) - return aosp_branch - print('new_aosp_branch="unknown"') - return 'unknown' + try: + for aosp_branch in aosp_branches: + output = base64.decodebytes(urllib.request.urlopen(BUILD_ID_URL.format("heads/" + aosp_branch)).read()).decode() + for line in output.split('\n'): + if BUILD_ID_FILTER in line: + found_build_id = line.split("=")[1] + if found_build_id == wanted_build_id: + print('new_aosp_branch="{0}"'.format(aosp_branch)) + return aosp_branch + print('new_aosp_branch="unknown"') + return 'unknown' + except Exception as e: + print('new_aosp_branch="unknown"') + return 'unknown' def get_all_aosp_tags(tag_filter): all_tags = [] - for line in cmd.Git().ls_remote("--sort=v:refname", PLATFORM_BUILD_URL, tag_filter, tags=True, refs=True).split('\n'): - try: - (ref, tag) = line.split('\t') - except ValueError: - pass - all_tags.append(tag.replace("refs/tags/", "")) - return all_tags + try: + for line in cmd.Git().ls_remote("--sort=v:refname", PLATFORM_BUILD_URL, tag_filter, tags=True, refs=True).split('\n'): + try: + (ref, tag) = line.split('\t') + except ValueError: + pass + all_tags.append(tag.replace("refs/tags/", "")) + return all_tags + except Exception as e: + return all_tags def get_aosp_tag_for_build_id(aosp_tags, wanted_build_id): - for aosp_tag in aosp_tags: - output = base64.decodebytes(urllib.request.urlopen(BUILD_ID_URL.format("tags/" + aosp_tag)).read()).decode() - for line in output.split('\n'): - if BUILD_ID_FILTER in line: - found_build_id = line.split("=")[1] - if found_build_id == wanted_build_id: - print('new_aosp_tag="{0}"'.format(aosp_tag)) - return aosp_tag - print('new_aosp_tag="unknown"') - return 'unknown' + try: + for aosp_tag in aosp_tags: + output = base64.decodebytes(urllib.request.urlopen(BUILD_ID_URL.format("tags/" + aosp_tag)).read()).decode() + for line in output.split('\n'): + if BUILD_ID_FILTER in line: + found_build_id = line.split("=")[1] + if found_build_id == wanted_build_id: + print('new_aosp_tag="{0}"'.format(aosp_tag)) + return aosp_tag + print('new_aosp_tag="unknown"') + return 'unknown' + except Exception as e: + print('new_aosp_tag="unknown"') + return 'unknown' def get_security_patch_for_aosp_tag(aosp_tag): try: