diff options
author | George Burgess IV <gbiv@google.com> | 2023-07-27 11:36:12 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-07-27 18:56:10 +0000 |
commit | 4a3fac641ea7035f6403fb4e0b97a54ac9160e93 (patch) | |
tree | 6223003bc3b664ab25dc8db90b2b8c9ed078955b | |
parent | 0a6e2019ecc0c5ddfd78642db72ec176b10bd254 (diff) | |
download | toolchain-utils-4a3fac641ea7035f6403fb4e0b97a54ac9160e93.tar.gz |
auto_delete_nightly_test_data: use `|=` for return values
follow-up given feedback on crrev.com/c/4723016
BUG=None
TEST=Unittests
Change-Id: I7f9236785f897dbb1f494fb4cef9baf851c56943
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/4726282
Reviewed-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Commit-Queue: George Burgess <gbiv@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-x | auto_delete_nightly_test_data.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/auto_delete_nightly_test_data.py b/auto_delete_nightly_test_data.py index ec459bef..06d02067 100755 --- a/auto_delete_nightly_test_data.py +++ b/auto_delete_nightly_test_data.py @@ -16,7 +16,7 @@ import stat import sys import time import traceback -from typing import Callable +from typing import Callable, List from cros_utils import command_executer from cros_utils import constants @@ -181,7 +181,7 @@ def CleanChromeOsImageFiles( return errors -def CleanChromeOsTmpAndImages(days_to_preserve=1, dry_run=False): +def CleanChromeOsTmpAndImages(days_to_preserve=1, dry_run=False) -> int: """Delete temporaries, images under crostc/chromeos.""" chromeos_chroot_tmp = os.path.join( constants.CROSTC_WORKSPACE, "chromeos", "out", "tmp" @@ -189,26 +189,26 @@ def CleanChromeOsTmpAndImages(days_to_preserve=1, dry_run=False): # Clean files in tmp directory rv = CleanChromeOsTmpFiles(chromeos_chroot_tmp, days_to_preserve, dry_run) # Clean image files in *-tryjob directories - rv += CleanChromeOsImageFiles( + rv |= CleanChromeOsImageFiles( chromeos_chroot_tmp, "-tryjob", days_to_preserve, dry_run ) # Clean image files in *-release directories - rv += CleanChromeOsImageFiles( + rv |= CleanChromeOsImageFiles( chromeos_chroot_tmp, "-release", days_to_preserve, dry_run ) # Clean image files in *-pfq directories - rv += CleanChromeOsImageFiles( + rv |= CleanChromeOsImageFiles( chromeos_chroot_tmp, "-pfq", days_to_preserve, dry_run ) # Clean image files in *-llvm-next-nightly directories - rv += CleanChromeOsImageFiles( + rv |= CleanChromeOsImageFiles( chromeos_chroot_tmp, "-llvm-next-nightly", days_to_preserve, dry_run ) return rv -def CleanOldCLs(days_to_preserve="1", dry_run=False): +def CleanOldCLs(days_to_preserve: str = "1", dry_run: bool = False) -> int: """Abandon old CLs created by automation tooling.""" ce = command_executer.GetCommandExecuter() chromeos_root = os.path.join(constants.CROSTC_WORKSPACE, "chromeos") @@ -245,7 +245,7 @@ def CleanChromeTelemetryTmpFiles(dry_run: bool) -> int: ) -def Main(argv): +def Main(argv: List[str]) -> int: """Delete nightly test data directories, tmps and test images.""" options = ProcessArguments(argv) ## Clean temporaries, images under crostc/chromeos @@ -254,14 +254,13 @@ def Main(argv): ) # Clean CLs that are not updated in last 2 weeks. - rv += CleanOldCLs("14", options.dry_run) + rv |= CleanOldCLs("14", options.dry_run) # Clean telemetry temporaries from chrome source tree inside chroot. - rv += CleanChromeTelemetryTmpFiles(options.dry_run) + rv |= CleanChromeTelemetryTmpFiles(options.dry_run) - return rv + return 1 if rv else 0 if __name__ == "__main__": - retval = Main(sys.argv[1:]) - sys.exit(retval) + sys.exit(Main(sys.argv[1:])) |