Commit 08cc5fae authored by José Henrique's avatar José Henrique
Browse files

Fix exception handling

parent 5b71881b
......@@ -25,11 +25,9 @@ if __name__ == "__main__":
print("Build success, running post build actions...\n")
start_post_build(init_post_build_env_vars(build_env_vars))
else:
raise Exception("Build failed")
raise Exception("Build failed.")
except Exception:
traceback.print_exc()
print("Build failed.\n")
cleanup()
sys.exit(1)
cleanup()
sys.exit(0)
......@@ -119,6 +119,7 @@ def start_build(environment_vars):
pull_image(image_name)
print("Starting build container, with environment variables: " +
json.dumps(environment_vars))
time.sleep(2)
try:
stream_container_logs(container_name)
time.sleep(1)
......
......@@ -78,7 +78,7 @@ def extract_recovery(post_build_env_vars):
file_to_extract) is False):
file_to_extract = "IMAGES/boot.img"
if not extract_from_target_files(target_files_path, file_to_extract):
sys.exit("Failed to extract recovery")
raise Exception("Failed to extract recovery")
os.rename(file_to_extract, post_build_env_vars["aosp_recovery_path"])
os.rmdir("IMAGES")
print("AOSP recovery extracted to " +
......
#!/usr/bin/env python3
import os
import glob
import sys
import shutil
......@@ -48,7 +47,7 @@ def init_post_build_env_vars(build_env_vars):
"/out/target/product/*/recovery/root/prop.default"))
if "org.pixelexperience.version.display" not in build_prop:
sys.exit(
raise Exception(
"Unable to find org.pixelexperience.version.display in build.prop")
result["build_name"] = (
build_prop["org.pixelexperience.version.display"] + ".zip")
......@@ -65,7 +64,7 @@ def init_post_build_env_vars(build_env_vars):
result["unsigned_target_files_path"] = find_file(
unsigned_target_files_path_glob)
if result["unsigned_target_files_path"] is None:
sys.exit("Unable to find file: " + unsigned_target_files_path_glob)
raise Exception("Unable to find file: " + unsigned_target_files_path_glob)
result["target_files_path"] = (
result["build_name"].replace(".zip", "_target_files.zip"))
result["target_files_compressed_path"] = (
......
......@@ -39,7 +39,7 @@ def sign_target_files_apks(unsigned_target_files_path, dest_target_files_path,
cmd += " " + dest_target_files_path
result = run_command(cmd)
if result != 0:
sys.exit(
raise Exception(
"Failed to run sign_target_files_apks, process returned code " +
str(result))
......@@ -62,7 +62,7 @@ def ota_from_target_files(target_files_path,
cmd += " " + dest_file_path
result = run_command(cmd)
if result != 0:
sys.exit(
raise Exception(
"Failed to run ota_from_target_files, process returned code " +
str(result))
......@@ -71,7 +71,7 @@ def compress_target_files(target_files_path, dest_file_path):
cmd = "zstd -f -3 " + target_files_path + " -o " + dest_file_path
result = run_command(cmd)
if result != 0:
sys.exit(
raise Exception(
"Failed to run zstd, process returned code " +
str(result))
......@@ -80,7 +80,7 @@ def decompress_target_files(target_files_path):
cmd = "zstd -d -f --rm " + target_files_path
result = run_command(cmd)
if result != 0:
sys.exit(
raise Exception(
"Failed to run zstd, process returned code " +
str(result))
......@@ -167,7 +167,7 @@ def get_artifact_info(device, build):
print("Failed, server returned: " +
str(status_code) + ", trying again in 60 seconds...")
if i == 5:
sys.exit(1)
raise Exception("Failed to get artifact info")
pass
time.sleep(60)
return False
......@@ -188,7 +188,7 @@ def download_artifact(device, build, destination_path):
return True
print("Download failed, trying again in 60 seconds...")
time.sleep(60)
sys.exit(
raise Exception(
"Failed to download artifact, process returned code " +
str(result))
......@@ -207,9 +207,9 @@ def validate_release_tools(release_tools_path):
groupNum += 1
import_name = match.group(groupNum)
if import_name not in allowed_imports:
sys.exit("releasetools: Import not allowed: " +
raise Exception("releasetools: Import not allowed: " +
import_name)
text = text.replace(" ", "")
for keyword in prohibited_keywords:
if keyword in text:
sys.exit("releasetools: Call not allowed: " + keyword)
raise Exception("releasetools: Call not allowed: " + keyword)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment