From 51639d66249a2887054d02f6766bb1797624e594 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Wed, 27 May 2020 16:41:57 +0000 Subject: [PATCH] Update exit codes --- scripts/check/archived.py | 3 ++- scripts/check/brands.py | 7 ++++--- scripts/check/fork.py | 3 ++- scripts/check/owner.py | 3 ++- scripts/check/repository.py | 5 +++-- scripts/check/wheels.py | 10 ++++------ scripts/helpers/domain.py | 5 +++-- scripts/helpers/integration_path.py | 4 +++- scripts/helpers/manifest.py | 3 ++- 9 files changed, 25 insertions(+), 18 deletions(-) diff --git a/scripts/check/archived.py b/scripts/check/archived.py index 4b7bbae..623319a 100644 --- a/scripts/check/archived.py +++ b/scripts/check/archived.py @@ -17,7 +17,8 @@ async def check(): repo = repository.attributes if repo["archived"]: - exit(1) + exit("Repository is archived") + if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(check()) diff --git a/scripts/check/brands.py b/scripts/check/brands.py index b1156ee..1e93e64 100644 --- a/scripts/check/brands.py +++ b/scripts/check/brands.py @@ -28,9 +28,10 @@ async def check(): repository = await github.get_repo("home-assistant/brands") files = await repository.get_contents("custom_integrations") if domain not in [x.attributes["name"] for x in files]: - print(f"{domain} is not added to https://github.com/home-assistant/brands") - print("This is needed to ensure the best possible experience for the user") - exit(1) + exit( + f"{domain} is not added to https://github.com/home-assistant/brands, " + + "this is needed to ensure the best possible experience for the user" + ) else: print( f"{domain} is added to https://github.com/home-assistant/brands, NICE!" diff --git a/scripts/check/fork.py b/scripts/check/fork.py index cd5c4ec..6901b7c 100644 --- a/scripts/check/fork.py +++ b/scripts/check/fork.py @@ -17,7 +17,8 @@ async def check(): repo = repository.attributes if repo["fork"]: - exit(1) + exit(78) + if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(check()) diff --git a/scripts/check/owner.py b/scripts/check/owner.py index c8fbaa7..527eb1f 100644 --- a/scripts/check/owner.py +++ b/scripts/check/owner.py @@ -24,7 +24,8 @@ async def check(): print(f"{ACTOR} is the owner of the repository") return - exit(1) + exit(78) + if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(check()) diff --git a/scripts/check/repository.py b/scripts/check/repository.py index 232f11c..a2881e6 100644 --- a/scripts/check/repository.py +++ b/scripts/check/repository.py @@ -17,12 +17,13 @@ async def check(): repository = await github.get_repo(repo) repo = repository.attributes - if not repo["has_issues"]: issues.append("Issues not enabled.") if not repo["description"]: - issues.append("No description. (https://hacs.xyz/docs/publish/start#description)") + issues.append( + "No description. (https://hacs.xyz/docs/publish/start#description)" + ) if not repo["topics"]: issues.append("No topics. (https://hacs.xyz/docs/publish/start#topics)") diff --git a/scripts/check/wheels.py b/scripts/check/wheels.py index 46aa4f3..91940d0 100644 --- a/scripts/check/wheels.py +++ b/scripts/check/wheels.py @@ -22,8 +22,7 @@ async def check(): domain = manifest.get("domain") requirements = manifest.get("requirements") if domain is None: - print("No domain") - exit(1) + exit("No domain") if not requirements: print("No requirements found") @@ -38,11 +37,10 @@ async def check(): f"{domain} is added to https://github.com/home-assistant/wheels-custom-integrations, NICE!" ) return - print( - f"{domain} is not added to https://github.com/home-assistant/wheels-custom-integrations" + exit( + f"{domain} is not added to https://github.com/home-assistant/wheels-custom-integrations, " + + "this is needed to ensure the best possible experience for the user" ) - print("This is needed to ensure the best possible experience for the user") - exit(1) if __name__ == "__main__": diff --git a/scripts/helpers/domain.py b/scripts/helpers/domain.py index 7457a78..29bc956 100644 --- a/scripts/helpers/domain.py +++ b/scripts/helpers/domain.py @@ -3,10 +3,11 @@ import os from glob import glob from scripts.helpers.manifest import get_manifest + def get_domain(): manifest = get_manifest() - return manifest.get('domain') + return manifest.get("domain") if __name__ == "__main__": - print(get_domain()) \ No newline at end of file + print(get_domain()) diff --git a/scripts/helpers/integration_path.py b/scripts/helpers/integration_path.py index cdd0f98..81994fb 100644 --- a/scripts/helpers/integration_path.py +++ b/scripts/helpers/integration_path.py @@ -2,6 +2,7 @@ import json import os from glob import glob + def get_integration_path(): files = [] for dir, _, _ in os.walk("/tmp/addition"): @@ -12,5 +13,6 @@ def get_integration_path(): exit(1) return files.pop().replace("/manifest.json", "") + if __name__ == "__main__": - print(get_integration_path()) \ No newline at end of file + print(get_integration_path()) diff --git a/scripts/helpers/manifest.py b/scripts/helpers/manifest.py index 0260a7b..d5cb989 100644 --- a/scripts/helpers/manifest.py +++ b/scripts/helpers/manifest.py @@ -3,9 +3,10 @@ import os from glob import glob from scripts.helpers.integration_path import get_integration_path + def get_manifest(): manifest = f"{get_integration_path()}/manifest.json" with open(manifest, "r") as mf: manifest = json.loads(mf.read()) - return manifest or {} \ No newline at end of file + return manifest or {}