aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2023-07-26 16:23:20 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-07-27 17:47:00 +0000
commit0a6e2019ecc0c5ddfd78642db72ec176b10bd254 (patch)
treeaf640e3494e70a9c54c273cefb9b6f3cf0519733
parent9d69fa5b02db7bc7fb95e5e355ac2b9e0c476c51 (diff)
downloadtoolchain-utils-0a6e2019ecc0c5ddfd78642db72ec176b10bd254.tar.gz
auto_delete_nightly_test_data: clean up lints
BUG=b:293350157, b:288112082 TEST=Unittests, `repo upload` Change-Id: I1e82b619971092950c2f87fde54c8c72d145bf4c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/4723017 Reviewed-by: Jordan Abrahams-Whitehead <ajordanr@google.com> Commit-Queue: George Burgess <gbiv@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-xauto_delete_nightly_test_data.py33
1 files changed, 15 insertions, 18 deletions
diff --git a/auto_delete_nightly_test_data.py b/auto_delete_nightly_test_data.py
index d45d4f70..ec459bef 100755
--- a/auto_delete_nightly_test_data.py
+++ b/auto_delete_nightly_test_data.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
#
# Copyright 2019 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
@@ -10,10 +9,8 @@
__author__ = "shenhan@google.com (Han Shen)"
import argparse
-import datetime
import os
from pathlib import Path
-import re
import shutil
import stat
import sys
@@ -23,7 +20,6 @@ from typing import Callable
from cros_utils import command_executer
from cros_utils import constants
-from cros_utils import misc
def ProcessArguments(argv):
@@ -68,10 +64,10 @@ def RemoveAllSubdirsMatchingPredicate(
try:
dir_entries = list(base_dir.iterdir())
except FileNotFoundError as e:
- # We get this if the directory itself doesn't exist. Since we're cleaning
- # tempdirs, that's as good as a success. Further, the prior approach here
- # was using the `find` binary, which exits successfully if nothing is
- # found.
+ # We get this if the directory itself doesn't exist. Since we're
+ # cleaning tempdirs, that's as good as a success. Further, the prior
+ # approach here was using the `find` binary, which exits successfully
+ # if nothing is found.
print(f"Error enumerating {base_dir}'s contents; skipping removal: {e}")
return 0
@@ -81,8 +77,8 @@ def RemoveAllSubdirsMatchingPredicate(
continue
try:
- # Take the stat here and use that later, so we only need to check for a
- # nonexistent file once.
+ # Take the stat here and use that later, so we only need to check
+ # for a nonexistent file once.
st = file.stat()
except FileNotFoundError:
# This was deleted while were checking; ignore it.
@@ -108,21 +104,22 @@ def RemoveAllSubdirsMatchingPredicate(
shutil.rmtree(file, onerror=OnError)
- # Some errors can be other processes racing with us to delete things. Don't
- # count those as an error which we complain loudly about.
+ # Some errors can be other processes racing with us to delete things.
+ # Don't count those as an error which we complain loudly about.
if this_iteration_had_errors:
if file.exists():
had_errors = True
else:
print(
- f"Discarding removal errors for {file}; dir was still removed."
+ f"Discarding removal errors for {file}; dir was still "
+ "removed."
)
return 1 if had_errors else 0
def IsChromeOsTmpDeletionCandidate(file_name: str):
- """Returns whether the given basename can be deleted from a chroot's /tmp."""
+ """Returns whether the given basename can be deleted from chroot's /tmp."""
name_prefixes = (
"test_that_",
"cros-update",
@@ -171,13 +168,13 @@ def CleanChromeOsImageFiles(
try:
shutil.rmtree(subdir_path)
print(
- "Successfully cleaned chromeos image autotest directories "
- f"from {subdir_path!r}."
+ "Successfully cleaned chromeos image autotest "
+ f"directories from {subdir_path!r}."
)
except OSError:
print(
- "Some image autotest directories were not removed from "
- f'"{subdir_path}".'
+ "Some image autotest directories were not "
+ f'"removed from {subdir_path}".'
)
errors += 1