From 3f9eaa8b6fafc66c199635fda68a67bc7a1e37f2 Mon Sep 17 00:00:00 2001 From: Elliot Jordan Date: Tue, 24 Dec 2024 11:44:47 -0800 Subject: [PATCH 1/3] Remove trailing whitespace and adjust version for DeprecationWarning --- 25io/Mou.download.recipe | 2 +- 25io/Smaller.download.recipe | 2 +- Boom/Boom2.download.recipe | 2 +- CaseApps/SofaControl.download.recipe | 2 +- CaseApps/Tags.download.recipe | 2 +- DeliciousMonster/DeliciousLibrary.download.recipe | 2 +- Deltopia/DeltaWalker.download.recipe | 2 +- Folio/Folio.download.recipe | 2 +- GeometersSketchpad5/GSP5.download.recipe | 2 +- Gikken/Tokens.download.recipe | 2 +- Kite/Kite.download.recipe | 4 ++-- LiveSurfaceContext/LiveSurfaceContext.download.recipe | 2 +- NDI/PalakisNDIRuntime.download.recipe | 2 +- NothingMagical/Whiskey.download.recipe | 2 +- ProfitTrain/ProfitTrain.download.recipe | 2 +- RecordIt/RecordIt.download.recipe | 2 +- Tenor/GIFforMac.download.recipe | 2 +- VirtualHost/VirtualHostX.download.recipe | 2 +- Zed/Zed.download.recipe | 2 +- Zyzzyva/Zyzzyva.download.recipe | 2 +- iMazing/iMazing.download.recipe | 2 +- 21 files changed, 22 insertions(+), 22 deletions(-) diff --git a/25io/Mou.download.recipe b/25io/Mou.download.recipe index 83a1ab3e..67f2a097 100644 --- a/25io/Mou.download.recipe +++ b/25io/Mou.download.recipe @@ -14,7 +14,7 @@ Mou MinimumVersion - 1.0.0 + 1.1 Process diff --git a/25io/Smaller.download.recipe b/25io/Smaller.download.recipe index 975fd922..5f0d9532 100644 --- a/25io/Smaller.download.recipe +++ b/25io/Smaller.download.recipe @@ -14,7 +14,7 @@ Smaller MinimumVersion - 1.0.0 + 1.1 Process diff --git a/Boom/Boom2.download.recipe b/Boom/Boom2.download.recipe index ed0a7eca..5dff5beb 100644 --- a/Boom/Boom2.download.recipe +++ b/Boom/Boom2.download.recipe @@ -14,7 +14,7 @@ Boom 2 MinimumVersion - 0.6.1 + 1.1 Process diff --git a/CaseApps/SofaControl.download.recipe b/CaseApps/SofaControl.download.recipe index 8af24b23..ad9346f2 100644 --- a/CaseApps/SofaControl.download.recipe +++ b/CaseApps/SofaControl.download.recipe @@ -14,7 +14,7 @@ Sofa Control MinimumVersion - 0.6.1 + 1.1 Process diff --git a/CaseApps/Tags.download.recipe b/CaseApps/Tags.download.recipe index 771e25a9..a5281bfb 100644 --- a/CaseApps/Tags.download.recipe +++ b/CaseApps/Tags.download.recipe @@ -14,7 +14,7 @@ Tags MinimumVersion - 0.6.1 + 1.1 Process diff --git a/DeliciousMonster/DeliciousLibrary.download.recipe b/DeliciousMonster/DeliciousLibrary.download.recipe index 3dcf709f..65222f92 100644 --- a/DeliciousMonster/DeliciousLibrary.download.recipe +++ b/DeliciousMonster/DeliciousLibrary.download.recipe @@ -14,7 +14,7 @@ Delicious Library 3 MinimumVersion - 0.6.1 + 1.1 Process diff --git a/Deltopia/DeltaWalker.download.recipe b/Deltopia/DeltaWalker.download.recipe index e3afe395..8ae4dccf 100644 --- a/Deltopia/DeltaWalker.download.recipe +++ b/Deltopia/DeltaWalker.download.recipe @@ -4,7 +4,7 @@ Description Downloads the latest version of DeltaWalker. - + Valid values for ARCH include: - x64 (default; Intel) - aarch64 (Apple Silicon) diff --git a/Folio/Folio.download.recipe b/Folio/Folio.download.recipe index 591d5930..c0c57fc3 100644 --- a/Folio/Folio.download.recipe +++ b/Folio/Folio.download.recipe @@ -14,7 +14,7 @@ Folio MinimumVersion - 0.6.1 + 1.1 Process diff --git a/GeometersSketchpad5/GSP5.download.recipe b/GeometersSketchpad5/GSP5.download.recipe index 2b626746..3ad6d4e4 100644 --- a/GeometersSketchpad5/GSP5.download.recipe +++ b/GeometersSketchpad5/GSP5.download.recipe @@ -4,7 +4,7 @@ Description Downloads the current release version of Geometer's Sketchpad 5. - + Not using CodeSignatureVerifier because version 5.06 resource envelope is obsolete (version 1 signature). Identifier com.github.homebysix.download.GSP5 diff --git a/Gikken/Tokens.download.recipe b/Gikken/Tokens.download.recipe index 013b424f..c7609929 100644 --- a/Gikken/Tokens.download.recipe +++ b/Gikken/Tokens.download.recipe @@ -19,7 +19,7 @@ upgrade from the old app from developer Peer Assembly. Tokens MinimumVersion - 1.0.0 + 1.1 Process diff --git a/Kite/Kite.download.recipe b/Kite/Kite.download.recipe index 0c9752f9..fbf759ab 100644 --- a/Kite/Kite.download.recipe +++ b/Kite/Kite.download.recipe @@ -12,7 +12,7 @@ Kite MinimumVersion - 0.6.1 + 1.1 Process @@ -22,7 +22,7 @@ warning_message Kite development ceased in 2022. (Details: https://web.archive.org/web/20241210091357/https://www.kite.com/blog/product/kite-is-saying-farewell/) - + This recipe is deprecated and will be removed in the future. diff --git a/LiveSurfaceContext/LiveSurfaceContext.download.recipe b/LiveSurfaceContext/LiveSurfaceContext.download.recipe index 9cb7f20c..d778958b 100644 --- a/LiveSurfaceContext/LiveSurfaceContext.download.recipe +++ b/LiveSurfaceContext/LiveSurfaceContext.download.recipe @@ -14,7 +14,7 @@ LiveSurface Context MinimumVersion - 0.6.1 + 1.1 Process diff --git a/NDI/PalakisNDIRuntime.download.recipe b/NDI/PalakisNDIRuntime.download.recipe index 427a4f1e..0421c821 100644 --- a/NDI/PalakisNDIRuntime.download.recipe +++ b/NDI/PalakisNDIRuntime.download.recipe @@ -12,7 +12,7 @@ PalakisNDIRuntime MinimumVersion - 1.0 + 1.1 Process diff --git a/NothingMagical/Whiskey.download.recipe b/NothingMagical/Whiskey.download.recipe index 9af70047..69424a62 100644 --- a/NothingMagical/Whiskey.download.recipe +++ b/NothingMagical/Whiskey.download.recipe @@ -14,7 +14,7 @@ Whiskey MinimumVersion - 0.6.1 + 1.1 Process diff --git a/ProfitTrain/ProfitTrain.download.recipe b/ProfitTrain/ProfitTrain.download.recipe index b704ccb6..1d6d177e 100644 --- a/ProfitTrain/ProfitTrain.download.recipe +++ b/ProfitTrain/ProfitTrain.download.recipe @@ -14,7 +14,7 @@ ProfitTrain MinimumVersion - 0.6.1 + 1.1 Process diff --git a/RecordIt/RecordIt.download.recipe b/RecordIt/RecordIt.download.recipe index 48d75ab4..7134b0d8 100644 --- a/RecordIt/RecordIt.download.recipe +++ b/RecordIt/RecordIt.download.recipe @@ -14,7 +14,7 @@ RecordIt MinimumVersion - 0.6.1 + 1.1 Process diff --git a/Tenor/GIFforMac.download.recipe b/Tenor/GIFforMac.download.recipe index e4f3dcdb..b3a3f538 100644 --- a/Tenor/GIFforMac.download.recipe +++ b/Tenor/GIFforMac.download.recipe @@ -14,7 +14,7 @@ GIF for Mac MinimumVersion - 0.6.1 + 1.1 Process diff --git a/VirtualHost/VirtualHostX.download.recipe b/VirtualHost/VirtualHostX.download.recipe index e61baaa0..0d2cc91a 100644 --- a/VirtualHost/VirtualHostX.download.recipe +++ b/VirtualHost/VirtualHostX.download.recipe @@ -14,7 +14,7 @@ VirtualHostX MinimumVersion - 0.6.1 + 1.1 Process diff --git a/Zed/Zed.download.recipe b/Zed/Zed.download.recipe index d7e612f9..03945a0f 100644 --- a/Zed/Zed.download.recipe +++ b/Zed/Zed.download.recipe @@ -4,7 +4,7 @@ Description Downloads the latest version of Zed. - + Valid values for ARCH include: - x86_64 (default, Intel) - aarch64 (Apple Silicon) diff --git a/Zyzzyva/Zyzzyva.download.recipe b/Zyzzyva/Zyzzyva.download.recipe index 6be7492c..fee702c9 100644 --- a/Zyzzyva/Zyzzyva.download.recipe +++ b/Zyzzyva/Zyzzyva.download.recipe @@ -12,7 +12,7 @@ Zyzzyva MinimumVersion - 1.0.0 + 1.1 Process diff --git a/iMazing/iMazing.download.recipe b/iMazing/iMazing.download.recipe index 3ead5cb8..0995a653 100644 --- a/iMazing/iMazing.download.recipe +++ b/iMazing/iMazing.download.recipe @@ -6,7 +6,7 @@ Created with Recipe Robot v1.0.3 (https://github.com/homebysix/recipe-robot) Description Downloads the latest version of iMazing. - + Tested with MAJOR_VERSION 2 and 3. Identifier com.github.homebysix.download.iMazing From 4495dd15c0297837e06642cf5a8deda73bdfeb51 Mon Sep 17 00:00:00 2001 From: Elliot Jordan Date: Tue, 24 Dec 2024 12:48:10 -0800 Subject: [PATCH 2/3] Update pre-commit config --- .pre-commit-config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f39b849..e96056f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.16.1 + rev: v1.17.0 hooks: - id: check-autopkg-recipes args: ["--recipe-prefix=com.github.homebysix.", "--strict", "--"] @@ -9,7 +9,7 @@ repos: exclude: ^Corel\/ - id: forbid-autopkg-trust-info - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files args: ["--maxkb=100"] @@ -28,7 +28,7 @@ repos: - id: trailing-whitespace args: ["--markdown-linebreak-ext=md"] - repo: https://github.com/ambv/black - rev: 24.4.2 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/pycqa/isort @@ -36,15 +36,15 @@ repos: hooks: - id: isort - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.1.1 hooks: - id: flake8 - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 + rev: 1.19.1 hooks: - id: blacken-docs - additional_dependencies: [black==24.1.1] - - repo: https://github.com/PyCQA/pylint - rev: v3.2.3 + additional_dependencies: [black==24.10.0] + - repo: https://github.com/pycqa/pylint + rev: v3.3.3 hooks: - id: pylint From 4ac26beded9b902dd7eb29d379f6cd9d3fa7fcb5 Mon Sep 17 00:00:00 2001 From: Elliot Jordan Date: Tue, 24 Dec 2024 12:49:15 -0800 Subject: [PATCH 3/3] Modernize subprocess calls and use f-strings instead of .format() --- BinaryFileVersioner/BinaryFileVersioner.py | 35 ++++++++----------- Cocktail/CocktailReleasesInfoProvider.py | 4 +-- Corel/CorelSerializer.py | 9 ++--- FindAndReplace/FindAndReplace.py | 2 +- GoToMeeting/GoToMeetingURLProvider.py | 6 ++-- Perforce/PerforceURLProvider.py | 8 ++--- R/RProjectURLProvider.py | 4 +-- VersionSplitter/VersionSplitter.py | 2 +- Zoom/Zoom7zUnarchiver.py | 32 +++++------------ ezeep/ezeepURLProvider.py | 4 +-- test/test_functional.py | 40 +++++++++++++--------- 11 files changed, 66 insertions(+), 80 deletions(-) diff --git a/BinaryFileVersioner/BinaryFileVersioner.py b/BinaryFileVersioner/BinaryFileVersioner.py index b98f761c..20bd894d 100644 --- a/BinaryFileVersioner/BinaryFileVersioner.py +++ b/BinaryFileVersioner/BinaryFileVersioner.py @@ -16,8 +16,7 @@ import os import re -import shlex -from subprocess import PIPE, Popen +import subprocess from autopkglib import Processor, ProcessorError # noqa: F401 @@ -47,31 +46,27 @@ def main(self): if not os.path.isfile("/bin/launchctl"): raise ProcessorError("/bin/launchctl is not present on this Mac.") - cmd = "/bin/launchctl plist __TEXT,__info_plist '{}'".format( - self.env["input_file_path"] - ) - with Popen( - shlex.split(cmd.strip()), stdin=PIPE, stdout=PIPE, stderr=PIPE, text=True - ) as proc: - out, err = proc.communicate() - exitcode = proc.returncode - - if exitcode != 0: - raise ProcessorError("/bin/launchctl failed with error: {}".format(err)) + cmd = [ + "/bin/launchctl", + "plist", + "__TEXT,__info_plist", + self.env["input_file_path"], + ] + proc = subprocess.run(cmd, check=False, capture_output=True, text=True) + if proc.returncode != 0: + raise ProcessorError(f"/bin/launchctl failed with error: {proc.stderr}") version_key = self.env.get("plist_version_key", "CFBundleShortVersionString") - pattern = '"{}" = "(.*)";'.format(version_key) - match = re.search(pattern, out) + pattern = f'"{version_key}" = "(.*)";' + match = re.search(pattern, proc.stdout) if match: self.env["version"] = match.group(1) - self.output("Found version: {}".format(self.env["version"])) + self.output(f"Found version: {self.env['version']}") else: raise ProcessorError( - "Unable to find a {} key in {}.".format( - self.env.get("plist_version_key", "CFBundleShortVersionString"), - self.env["input_file_path"], - ) + f"Unable to find a {self.env.get('plist_version_key', 'CFBundleShortVersionString')} " + f"key in {self.env['input_file_path']}." ) diff --git a/Cocktail/CocktailReleasesInfoProvider.py b/Cocktail/CocktailReleasesInfoProvider.py index 5648e8ce..76a0c04e 100644 --- a/Cocktail/CocktailReleasesInfoProvider.py +++ b/Cocktail/CocktailReleasesInfoProvider.py @@ -83,7 +83,7 @@ class CocktailReleasesInfoProvider(URLGetter): "major_version": { "required": False, "description": "Major version of macOS for which to download a " - "compatible Cocktail release. Default is %s" % DEFAULT_MAJOR_VERSION, + f"compatible Cocktail release. Default is {DEFAULT_MAJOR_VERSION}.", } } output_variables = { @@ -107,7 +107,7 @@ def main(self): # Determine and set output variables self.env["url"] = BASE_URL + RELEASES[major_version]["filename"] - self.output("Found URL: %s" % self.env["url"]) + self.output(f"Found URL: {self.env['url']}") self.env["bundle_id"] = RELEASES[major_version]["bundle_id"] # Determine and set code signature verification cert leaf diff --git a/Corel/CorelSerializer.py b/Corel/CorelSerializer.py index 1da6974c..7e92ad12 100644 --- a/Corel/CorelSerializer.py +++ b/Corel/CorelSerializer.py @@ -52,10 +52,7 @@ def license_info(self): """Return the product code and DTA file installed path for this Corel product by parsing the License.plist file in the Registration bundle.""" - license_path = ( - "%s/plugins/Registration.bundle/Contents/Resources/License.plist" - % self.env["RECIPE_CACHE_DIR"] - ) + license_path = f"{self.env['RECIPE_CACHE_DIR']}/plugins/Registration.bundle/Contents/Resources/License.plist" with open(license_path, "rb") as openfile: license_info = plistlib.load(openfile) return license_info["ProductID"], license_info["DTAFileInstalledPath"] @@ -65,7 +62,7 @@ def main(self): if not os.path.isfile(self.env["flat_pkg_path"]): raise ProcessorError( - "Provided flat_pkg_path does not exist: %s" % self.env["flat_pkg_path"] + f"Provided flat_pkg_path does not exist: {self.env['flat_pkg_path']}" ) create_dta = os.path.join(self.env["RECIPE_CACHE_DIR"], "plugins", "create_dta") @@ -78,7 +75,7 @@ def main(self): self.env["dta_path"] = dta_path self.env["dta_installed_path"] = dta_installed_path self.env["product_code"] = product_code - self.output("Serialized DTA file: %s" % dta_path) + self.output(f"Serialized DTA file: {dta_path}") if __name__ == "__main__": diff --git a/FindAndReplace/FindAndReplace.py b/FindAndReplace/FindAndReplace.py index e7404b56..e3cad540 100644 --- a/FindAndReplace/FindAndReplace.py +++ b/FindAndReplace/FindAndReplace.py @@ -53,7 +53,7 @@ def main(self): input_string = self.env["input_string"] find = self.env["find"] replace = self.env["replace"] - self.output('Replacing "%s" with "%s" in "%s".' % (find, replace, input_string)) + self.output(f'Replacing "{find}" with "{replace}" in "{input_string}".') self.env["output_string"] = self.env["input_string"].replace(find, replace) diff --git a/GoToMeeting/GoToMeetingURLProvider.py b/GoToMeeting/GoToMeetingURLProvider.py index e1f2efb4..699a0d78 100644 --- a/GoToMeeting/GoToMeetingURLProvider.py +++ b/GoToMeeting/GoToMeetingURLProvider.py @@ -53,7 +53,7 @@ class GoToMeetingURLProvider(URLGetter): "base_url": { "required": False, "description": "URL for the GoToMeeting " - "releases JSON feed. Default is %s" % BASE_URL, + f"releases JSON feed. Default is {BASE_URL}.", } } output_variables = { @@ -108,9 +108,9 @@ def main(self): base_url = self.env.get("base_url", BASE_URL) g2m_url, g2m_build = self.get_g2m_info(base_url) self.env["url"] = g2m_url - self.output("Found URL: %s" % self.env["url"]) + self.output(f"Found URL: {self.env['url']}") self.env["build"] = g2m_build - self.output("Build number: %s" % self.env["build"]) + self.output(f"Build number: {self.env['build']}") if __name__ == "__main__": diff --git a/Perforce/PerforceURLProvider.py b/Perforce/PerforceURLProvider.py index e67f510d..d0f9f57e 100644 --- a/Perforce/PerforceURLProvider.py +++ b/Perforce/PerforceURLProvider.py @@ -71,11 +71,11 @@ def recurse_subdirs(self, path, url): # Add trailing slash to prevent constant 301 redirects. if not url.endswith("/"): url = url + "/" - self.output("Searching %s for %s" % (url, path[0])) + self.output(f"Searching {url} for {path[0]}") # Get content of directory listing and parse for links matching path regex. html = self.download(url, text=True) - link_pattern = re.compile('' % path[0]) + link_pattern = re.compile(f'') links = re.findall(link_pattern, html) if len(links) == 0: # No match, toss back to parent caller and continue recursing. @@ -105,10 +105,10 @@ def main(self): url = self.recurse_subdirs(info["path"], BASE_URL + "/" + info["start"]) if not url: raise ProcessorError( - "Did not find a matching download URL for %s." % self.env["product"] + f"Did not find a matching download URL for {self.env['product']}." ) self.env["url"] = url - self.output("Found url: %s" % self.env["url"]) + self.output(f"Found url: {self.env['url']}") if __name__ == "__main__": diff --git a/R/RProjectURLProvider.py b/R/RProjectURLProvider.py index 90297594..1c9c869c 100644 --- a/R/RProjectURLProvider.py +++ b/R/RProjectURLProvider.py @@ -69,9 +69,9 @@ def main(self): # Set URL and version in environment self.env["url"] = url_base + m.groupdict()["file"] - self.output("Found url: %s" % self.env["url"]) + self.output(f"Found url: {self.env['url']}") self.env["version"] = m.groupdict()["vers"] - self.output("Found version: %s" % self.env["version"]) + self.output(f"Found version: {self.env['version']}") if __name__ == "__main__": diff --git a/VersionSplitter/VersionSplitter.py b/VersionSplitter/VersionSplitter.py index 989c9063..7d31e502 100644 --- a/VersionSplitter/VersionSplitter.py +++ b/VersionSplitter/VersionSplitter.py @@ -55,7 +55,7 @@ def main(self): split_on = self.env.get("split_on", " ") index = self.env.get("index", 0) self.env["version"] = self.env["version"].split(split_on)[index] - self.output("Split version: {}".format(self.env["version"])) + self.output(f"Split version: {self.env['version']}") if __name__ == "__main__": diff --git a/Zoom/Zoom7zUnarchiver.py b/Zoom/Zoom7zUnarchiver.py index 9e3092c7..de6d41c7 100644 --- a/Zoom/Zoom7zUnarchiver.py +++ b/Zoom/Zoom7zUnarchiver.py @@ -100,9 +100,7 @@ def main(self): try: os.makedirs(destination_path) except OSError as err: - raise ProcessorError( - "Can't create %s: %s" % (destination_path, err.strerror) - ) + raise ProcessorError(f"Can't create {destination_path}: {err.strerror}") elif self.env.get("purge_destination"): for entry in os.listdir(destination_path): path = os.path.join(destination_path, entry) @@ -112,24 +110,22 @@ def main(self): else: os.unlink(path) except OSError as err: - raise ProcessorError("Can't remove %s: %s" % (path, err.strerror)) + raise ProcessorError(f"Can't remove {path}: {err.strerror}") fmt = self.env.get("archive_format") if fmt is None: fmt = self.get_archive_format(archive_path) if not fmt: raise ProcessorError( - "Can't guess archive format for filename %s" - % os.path.basename(archive_path) + f"Can't guess archive format for filename {os.path.basename(archive_path)}" ) self.output( - "Guessed archive format '%s' from filename %s" - % (fmt, os.path.basename(archive_path)) + f"Guessed archive format '{fmt}' from filename {os.path.basename(archive_path)}" ) elif fmt not in EXTNS: raise ProcessorError( - "'%s' is not valid for the 'archive_format' variable. " - "Must be one of %s." % (fmt, ", ".join(EXTNS)) + f"'{fmt}' is not valid for the 'archive_format' variable. " + f"Must be one of {', '.join(EXTNS)}." ) if fmt == "zip": @@ -158,23 +154,13 @@ def main(self): cmd.append("-j") # Call the shell command. - try: - with subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE - ) as proc: - _, stderr = proc.communicate() - except OSError as err: - raise ProcessorError( - "%s execution failed with error code %d: %s" - % (os.path.basename(cmd[0]), err.errno, err.strerror) - ) + proc = subprocess.run(cmd, check=False, capture_output=True, text=True) if proc.returncode != 0: raise ProcessorError( - "Unarchiving %s with %s failed: %s" - % (archive_path, os.path.basename(cmd[0]), stderr) + f"Unarchiving {archive_path} with {os.path.basename(cmd[0])} failed: {proc.stderr}" ) - self.output("Unarchived %s to %s" % (archive_path, destination_path)) + self.output(f"Unarchived {archive_path} to {destination_path}") if __name__ == "__main__": diff --git a/ezeep/ezeepURLProvider.py b/ezeep/ezeepURLProvider.py index 094273c5..e7845724 100644 --- a/ezeep/ezeepURLProvider.py +++ b/ezeep/ezeepURLProvider.py @@ -88,9 +88,9 @@ def main(self): # Set URL and version in environment self.env["url"] = json.loads(response).get("url") - self.output("Found url: %s" % self.env["url"]) + self.output(f"Found url: {self.env['url']}") self.env["version"] = json.loads(response).get("version") - self.output("Found version: %s" % self.env["version"]) + self.output(f"Found version: {self.env['version']}") if __name__ == "__main__": diff --git a/test/test_functional.py b/test/test_functional.py index 95d26796..a791d8ab 100644 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -38,19 +38,19 @@ def check_recipe(relpath, recipe): """Parse the recipe and make sure it's valid.""" - assert_is_instance(recipe, dict, "{}: recipe is not a dict".format(relpath)) - assert_in("Identifier", recipe, "{}: no Identifier key".format(relpath)) + assert_is_instance(recipe, dict, f"{relpath}: recipe is not a dict") + assert_in("Identifier", recipe, f"{relpath}: no Identifier key") assert_true( recipe["Identifier"].startswith(IDENTIFIER_PREFIX) or recipe["Identifier"] in IDENTIFIER_EXEMPTIONS, - "{}: does not start with {}".format(relpath, IDENTIFIER_PREFIX), + f"{relpath}: does not start with {IDENTIFIER_PREFIX}", ) - assert_in("Input", recipe, "{}: no Input key".format(relpath)) - assert_in("Process", recipe, "{}: no Process key".format(relpath)) + assert_in("Input", recipe, f"{relpath}: no Input key") + assert_in("Process", recipe, f"{relpath}: no Process key") assert_not_in( "ParentRecipeTrustInfo", recipe, - "{}: has ParentRecipeTrustInfo key".format(relpath), + f"{relpath}: has ParentRecipeTrustInfo key", ) @@ -67,32 +67,42 @@ def run_recipe(relpath, recipe): # Skip any recipe that contains certain processors for proc_exc in PROCESSOR_EXCEPTIONS: if proc_exc in [x["Processor"] for x in recipe.get("Process", [{}])]: - print("Skipping due to %s." % proc_exc) + print(f"Skipping due to {proc_exc}.") return - retcode = subprocess.call( + proc = subprocess.run( [ AUTOPKG, "info", relpath, "--pull", "--quiet", - ] + ], + check=True, + capture_output=True, + text=True, ) assert_equal( - retcode, 0, "{}: autopkg info exited with code {}".format(relpath, retcode) + proc.returncode, + 0, + f"{relpath}: autopkg info exited with code {proc.returncode}", ) - retcode = subprocess.call( + proc = subprocess.run( [ AUTOPKG, "run", relpath, "--report-plist=test/report.plist", "--quiet", - ] + ], + check=True, + capture_output=True, + text=True, ) assert_equal( - retcode, 0, "{}: autopkg run exited with code {}".format(relpath, retcode) + proc.returncode, + 0, + f"{relpath}: autopkg run exited with code {proc.returncode}", ) @@ -120,9 +130,7 @@ def test_functional(): # Check and run each recipe we found. for index, recipe_path in enumerate(recipe_paths): - print( - "Testing {} ({} of {})...".format(recipe_path, index + 1, len(recipe_paths)) - ) + print(f"Testing {recipe_path} ({index + 1} of {len(recipe_paths)})...") with open(recipe_path, "rb") as infile: recipe = plistlib.load(infile) yield check_recipe, recipe_path, recipe