From 5df13bcb8cebe23bd9f59d6700cd064738bd255e Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Sat, 5 Dec 2020 14:24:50 +0100 Subject: [PATCH 1/2] Catch exception when testing find_sdk_tools_cmd In 1c7df94e find_sdk_tools_cmd was changed to throw an FDroidException when the sdk tools where not found instead of returning None. --- tests/common.TestCase | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/common.TestCase b/tests/common.TestCase index d42bfe85..4ba80c0d 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -92,10 +92,12 @@ class CommonTest(unittest.TestCase): if os.path.exists(os.path.join(os.getenv('ANDROID_HOME'), 'tools', 'android')): tools.append('android') for cmd in tools: - path = fdroidserver.common.find_sdk_tools_cmd(cmd) - if path is not None: + try: + path = fdroidserver.common.find_sdk_tools_cmd(cmd) self.assertTrue(os.path.exists(path)) self.assertTrue(os.path.isfile(path)) + except fdroidserver.exception.FDroidException: + pass def test_find_sdk_tools_cmd(self): fdroidserver.common.config = dict() From 66d0e6b1f9739f96ee3dce6f7a9113a7e8af4ef2 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Sun, 6 Dec 2020 10:28:42 +0100 Subject: [PATCH 2/2] find_sdk_tools_cmd always raise exception if not found test_sdk_exists() succeeds on an empty directory so it does not give any new information. Contrary, test_sdk_exists() succeeds on an empty directory, so find_sdk_tools_cmd() returned None even though the tools where not found, before. --- fdroidserver/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 63a52b30..c75338f1 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -520,8 +520,8 @@ def find_sdk_tools_cmd(cmd): test_aapt_version(path) return path # did not find the command, exit with error message - if not test_sdk_exists(config): - raise FDroidException(_("Android SDK not found!")) + test_sdk_exists(config) # ignore result so None is never returned + raise FDroidException(_("Android SDK tool {cmd} found!").format(cmd=cmd)) def test_aapt_version(aapt):