diff options
author | Jordan R Abrahams-Whitehead <ajordanr@google.com> | 2023-07-10 20:12:36 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-07-11 17:36:39 +0000 |
commit | c283de4032ddc8acda707bce5b18ab48c7008143 (patch) | |
tree | 07869e1ae0dfc9d1c6e8b38bf8e7b0ab54e48ac0 /cros_utils | |
parent | f8facb3028d430d26af12515baceba9773856617 (diff) | |
download | toolchain-utils-c283de4032ddc8acda707bce5b18ab48c7008143.tar.gz |
cros_utils: Reformat buildbot_utils
This attempts to isolate some of the style changes to make cros lint
happier. It's not all encompassing.
BUG=None
TEST=./run_tests_for.py cros_utils/*test.py
Change-Id: I55e264771ab2aa7160b43679602955dcfcf72beb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/4674781
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'cros_utils')
-rw-r--r-- | cros_utils/buildbot_utils.py | 51 | ||||
-rwxr-xr-x | cros_utils/buildbot_utils_unittest.py | 12 |
2 files changed, 28 insertions, 35 deletions
diff --git a/cros_utils/buildbot_utils.py b/cros_utils/buildbot_utils.py index 8f0ce5e0..36c68c13 100644 --- a/cros_utils/buildbot_utils.py +++ b/cros_utils/buildbot_utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -41,13 +40,13 @@ def PeekTrybotImage(chromeos_root, buildbucket_id): """Get the artifact URL of a given tryjob. Args: - buildbucket_id: buildbucket-id - chromeos_root: root dir of chrome os checkout + buildbucket_id: buildbucket-id + chromeos_root: root dir of chrome os checkout Returns: - (status, url) where status can be 'pass', 'fail', 'running', + (status, url) where status can be 'pass', 'fail', 'running', and url looks like: - gs://chromeos-image-archive/trybot-elm-release-tryjob/R67-10468.0.0-b20789 + gs://chromeos-image-archive/trybot-elm-release-tryjob/R67-10468.0.0-b20789 """ command = ( "cros buildresult --report json --buildbucket-id %s" % buildbucket_id @@ -72,10 +71,10 @@ def ParseTryjobBuildbucketId(msg): """Find the buildbucket-id in the messages from `cros tryjob`. Args: - msg: messages from `cros tryjob` + msg: messages from `cros tryjob` Returns: - buildbucket-id, which will be passed to `cros buildresult` + buildbucket-id, which will be passed to `cros buildresult` """ output_list = ast.literal_eval(msg) output_dict = output_list[0] @@ -94,17 +93,17 @@ def SubmitTryjob( """Calls `cros tryjob ...` Args: - chromeos_root: the path to the ChromeOS root, needed for finding chromite - and launching the buildbot. - buildbot_name: the name of the buildbot queue, such as lumpy-release or - daisy-paladin. - patch_list: a python list of the patches, if any, for the buildbot to use. - tryjob_flags: See cros tryjob --help for available options. - build_toolchain: builds and uses the latest toolchain, rather than the - prebuilt one in SDK. + chromeos_root: the path to the ChromeOS root, needed for finding chromite + and launching the buildbot. + buildbot_name: the name of the buildbot queue, such as lumpy-release or + daisy-paladin. + patch_list: a python list of the patches, if any, for the buildbot to use. + tryjob_flags: See cros tryjob --help for available options. + build_toolchain: builds and uses the latest toolchain, rather than the + prebuilt one in SDK. Returns: - buildbucket id + buildbucket id """ patch_arg = "" if patch_list: @@ -151,19 +150,19 @@ def GetTrybotImage( artifact (if one was created), and returns that artifact name. Args: - chromeos_root: the path to the ChromeOS root, needed for finding chromite - and launching the buildbot. - buildbot_name: the name of the buildbot queue, such as lumpy-release or - daisy-paladin. - patch_list: a python list of the patches, if any, for the buildbot to use. - tryjob_flags: See cros tryjob --help for available options. - build_toolchain: builds and uses the latest toolchain, rather than the + chromeos_root: the path to the ChromeOS root, needed for finding chromite + and launching the buildbot. + buildbot_name: the name of the buildbot queue, such as lumpy-release or + daisy-paladin. + patch_list: a python list of the patches, if any, for the buildbot to use. + tryjob_flags: See cros tryjob --help for available options. + build_toolchain: builds and uses the latest toolchain, rather than the prebuilt one in SDK. - asynchronous: don't wait for artifacts; just return the buildbucket id + asynchronous: don't wait for artifacts; just return the buildbucket id Returns: - (buildbucket id, partial image url) e.g. - (8952271933586980528, trybot-elm-release-tryjob/R67-10480.0.0-b2373596) + (buildbucket id, partial image url) e.g. + (8952271933586980528, trybot-elm-release-tryjob/R67-10480.0.0-b2373596) """ buildbucket_id = SubmitTryjob( chromeos_root, buildbot_name, patch_list, tryjob_flags, build_toolchain diff --git a/cros_utils/buildbot_utils_unittest.py b/cros_utils/buildbot_utils_unittest.py index 2c9585b5..9e006f20 100755 --- a/cros_utils/buildbot_utils_unittest.py +++ b/cros_utils/buildbot_utils_unittest.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# # Copyright 2018 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -154,7 +152,7 @@ class TrybotTest(unittest.TestCase): ) mocked_imageexist.return_value = True image = buildbot_utils.GetLatestImage("", IMAGE_DIR) - self.assertEqual(image, "{0}/R78-12423.0.0".format(IMAGE_DIR)) + self.assertEqual(image, f"{IMAGE_DIR}/R78-12423.0.0") def testGetLatestImageInvalid(self): with patch.object( @@ -190,9 +188,7 @@ class TrybotTest(unittest.TestCase): image = buildbot_utils.GetLatestRecipeImage("", IMAGE_DIR) self.assertEqual( image, - "{0}/R83-13003.0.0-30218-8884712858556419".format( - IMAGE_DIR - ), + f"{IMAGE_DIR}/R83-13003.0.0-30218-8884712858556419", ) def testGetLatestRecipeImageInvalid(self): @@ -232,9 +228,7 @@ class TrybotTest(unittest.TestCase): image = buildbot_utils.GetLatestRecipeImage("", IMAGE_DIR) self.assertEqual( image, - "{0}/R83-13003.0.0-30196-8884755532184725".format( - IMAGE_DIR - ), + f"{IMAGE_DIR}/R83-13003.0.0-30196-8884755532184725", ) |