1
0
Fork 0

autoupdate_app_sources: use get_apps_repo

This commit is contained in:
Félix Piédallu 2024-08-13 11:16:27 +02:00 committed by Salamandar
parent a039a43ed6
commit 539dc79e51

View file

@ -27,13 +27,11 @@ from rest_api import (
DownloadPageAPI, DownloadPageAPI,
RefType, RefType,
) # noqa: E402,E501 pylint: disable=import-error,wrong-import-position ) # 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 import appslib.logging_sender # noqa: E402 pylint: disable=import-error,wrong-import-position
from appslib.utils import ( from appslib.utils import (
get_catalog, get_catalog,
) # noqa: E402 pylint: disable=import-error,wrong-import-position ) # 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 TOOLS_DIR = Path(__file__).resolve().parent.parent
@ -62,22 +60,13 @@ def get_github() -> tuple[
]: ]:
try: try:
github_login = ( github_login = (
(TOOLS_DIR / ".github_login") (TOOLS_DIR / ".github_login").open("r", encoding="utf-8").read().strip()
.open("r", encoding="utf-8")
.read()
.strip()
) )
github_token = ( github_token = (
(TOOLS_DIR / ".github_token") (TOOLS_DIR / ".github_token").open("r", encoding="utf-8").read().strip()
.open("r", encoding="utf-8")
.read()
.strip()
) )
github_email = ( github_email = (
(TOOLS_DIR / ".github_email") (TOOLS_DIR / ".github_email").open("r", encoding="utf-8").read().strip()
.open("r", encoding="utf-8")
.read()
.strip()
) )
auth = (github_login, github_token) auth = (github_login, github_token)
@ -89,7 +78,7 @@ def get_github() -> tuple[
return None, None, None 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 = [ apps_flagged_as_working_and_on_yunohost_apps_org = [
app app
for app, infos in get_catalog().items() for app, infos in get_catalog().items()
@ -100,7 +89,7 @@ def apps_to_run_auto_update_for() -> list[str]:
relevant_apps = [] relevant_apps = []
for app in apps_flagged_as_working_and_on_yunohost_apps_org: for app in apps_flagged_as_working_and_on_yunohost_apps_org:
try: try:
manifest_toml = app_cache_folder(app) / "manifest.toml" manifest_toml = cache_path / app / "manifest.toml"
if manifest_toml.exists(): if manifest_toml.exists():
manifest = toml.load(manifest_toml.open("r", encoding="utf-8")) manifest = toml.load(manifest_toml.open("r", encoding="utf-8"))
sources = manifest.get("resources", {}).get("sources", {}) sources = manifest.get("resources", {}).get("sources", {})
@ -746,6 +735,7 @@ def main() -> None:
parser.add_argument( parser.add_argument(
"-j", "--processes", type=int, default=multiprocessing.cpu_count() "-j", "--processes", type=int, default=multiprocessing.cpu_count()
) )
get_apps_repo.add_args(parser)
args = parser.parse_args() args = parser.parse_args()
appslib.logging_sender.enable() appslib.logging_sender.enable()
@ -757,11 +747,16 @@ def main() -> None:
logging.error("--pr requires --commit") logging.error("--pr requires --commit")
sys.exit(1) sys.exit(1)
get_apps_repo.from_args(args)
cache_path = get_apps_repo.cache_path(args)
# Handle apps or no apps # 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_already = {} # for which a PR already exists
apps_updated = {} apps_updated = {}
apps_failed = {} apps_failed = {}
print(apps)
exit()
with multiprocessing.Pool(processes=args.processes) as pool: with multiprocessing.Pool(processes=args.processes) as pool:
tasks = pool.imap( tasks = pool.imap(