From 539dc79e51dba6b6a66fab90ac3a03860463e456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 13 Aug 2024 11:16:27 +0200 Subject: [PATCH] autoupdate_app_sources: use get_apps_repo --- .../autoupdate_app_sources.py | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/autoupdate_app_sources/autoupdate_app_sources.py b/autoupdate_app_sources/autoupdate_app_sources.py index 0f13bb6..4061886 100755 --- a/autoupdate_app_sources/autoupdate_app_sources.py +++ b/autoupdate_app_sources/autoupdate_app_sources.py @@ -27,13 +27,11 @@ from rest_api import ( DownloadPageAPI, RefType, ) # noqa: E402,E501 pylint: disable=import-error,wrong-import-position +import appslib.get_apps_repo as get_apps_repo import appslib.logging_sender # noqa: E402 pylint: disable=import-error,wrong-import-position from appslib.utils import ( get_catalog, ) # noqa: E402 pylint: disable=import-error,wrong-import-position -from app_caches import ( - app_cache_folder, -) # noqa: E402 pylint: disable=import-error,wrong-import-position TOOLS_DIR = Path(__file__).resolve().parent.parent @@ -62,22 +60,13 @@ def get_github() -> tuple[ ]: try: github_login = ( - (TOOLS_DIR / ".github_login") - .open("r", encoding="utf-8") - .read() - .strip() + (TOOLS_DIR / ".github_login").open("r", encoding="utf-8").read().strip() ) github_token = ( - (TOOLS_DIR / ".github_token") - .open("r", encoding="utf-8") - .read() - .strip() + (TOOLS_DIR / ".github_token").open("r", encoding="utf-8").read().strip() ) github_email = ( - (TOOLS_DIR / ".github_email") - .open("r", encoding="utf-8") - .read() - .strip() + (TOOLS_DIR / ".github_email").open("r", encoding="utf-8").read().strip() ) auth = (github_login, github_token) @@ -89,7 +78,7 @@ def get_github() -> tuple[ return None, None, None -def apps_to_run_auto_update_for() -> list[str]: +def apps_to_run_auto_update_for(cache_path: Path) -> list[str]: apps_flagged_as_working_and_on_yunohost_apps_org = [ app for app, infos in get_catalog().items() @@ -100,7 +89,7 @@ def apps_to_run_auto_update_for() -> list[str]: relevant_apps = [] for app in apps_flagged_as_working_and_on_yunohost_apps_org: try: - manifest_toml = app_cache_folder(app) / "manifest.toml" + manifest_toml = cache_path / app / "manifest.toml" if manifest_toml.exists(): manifest = toml.load(manifest_toml.open("r", encoding="utf-8")) sources = manifest.get("resources", {}).get("sources", {}) @@ -746,6 +735,7 @@ def main() -> None: parser.add_argument( "-j", "--processes", type=int, default=multiprocessing.cpu_count() ) + get_apps_repo.add_args(parser) args = parser.parse_args() appslib.logging_sender.enable() @@ -757,11 +747,16 @@ def main() -> None: logging.error("--pr requires --commit") sys.exit(1) + get_apps_repo.from_args(args) + cache_path = get_apps_repo.cache_path(args) + # Handle apps or no apps - apps = list(args.apps) if args.apps else apps_to_run_auto_update_for() + apps = list(args.apps) if args.apps else apps_to_run_auto_update_for(cache_path) apps_already = {} # for which a PR already exists apps_updated = {} apps_failed = {} + print(apps) + exit() with multiprocessing.Pool(processes=args.processes) as pool: tasks = pool.imap(