mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
find_deprecated: better handling of exceptions
This commit is contained in:
parent
5c1f202877
commit
6de9fa7f09
1 changed files with 27 additions and 22 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import traceback
|
||||||
import argparse
|
import argparse
|
||||||
import tomlkit
|
import tomlkit
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
@ -57,32 +58,36 @@ def upstream_last_update_ago(app: str) -> tuple[str, int | None]:
|
||||||
raise RuntimeError(f"App {app} doesn't have an upstream code link!")
|
raise RuntimeError(f"App {app} doesn't have an upstream code link!")
|
||||||
|
|
||||||
api = None
|
api = None
|
||||||
if upstream.startswith("https://github.com/"):
|
try:
|
||||||
api = GithubAPI(upstream, auth=get_github()[0])
|
if upstream.startswith("https://github.com/"):
|
||||||
|
api = GithubAPI(upstream, auth=get_github()[0])
|
||||||
|
|
||||||
if upstream.startswith("https://gitlab."):
|
if upstream.startswith("https://gitlab."):
|
||||||
api = GitlabAPI(upstream)
|
api = GitlabAPI(upstream)
|
||||||
|
|
||||||
if upstream.startswith("https://codeberg.org") or upstream.startswith("https://framagit.org"):
|
if upstream.startswith("https://codeberg.org") or upstream.startswith("https://framagit.org"):
|
||||||
api = GiteaForgejoAPI(upstream)
|
api = GiteaForgejoAPI(upstream)
|
||||||
|
|
||||||
if not api:
|
if not api:
|
||||||
autoupdate = manifest.get("resources", {}).get("sources", {}).get("main", {}).get("autoupdate")
|
autoupdate = manifest.get("resources", {}).get("sources", {}).get("main", {}).get("autoupdate")
|
||||||
if autoupdate:
|
if autoupdate:
|
||||||
strat = autoupdate["strategy"]
|
strat = autoupdate["strategy"]
|
||||||
if "gitea" in strat or "forgejo" in strat:
|
if "gitea" in strat or "forgejo" in strat:
|
||||||
api = GiteaForgejoAPI(upstream)
|
api = GiteaForgejoAPI(upstream)
|
||||||
|
|
||||||
if api:
|
if api:
|
||||||
if api.archived():
|
if api.archived():
|
||||||
# A stupid value that we know to be higher than the trigger value
|
# A stupid value that we know to be higher than the trigger value
|
||||||
return app, 1000
|
return app, 1000
|
||||||
|
|
||||||
last_commit = api.commits()[0]
|
last_commit = api.commits()[0]
|
||||||
date = last_commit["commit"]["author"]["date"]
|
date = last_commit["commit"]["author"]["date"]
|
||||||
date = datetime.datetime.fromisoformat(date)
|
date = datetime.datetime.fromisoformat(date)
|
||||||
ago: datetime.timedelta = datetime.datetime.now() - date.replace(tzinfo=None)
|
ago: datetime.timedelta = datetime.datetime.now() - date.replace(tzinfo=None)
|
||||||
return app, ago.days
|
return app, ago.days
|
||||||
|
except Exception:
|
||||||
|
logging.error(f"Exception while handling {app}", traceback.format_exc())
|
||||||
|
raise
|
||||||
|
|
||||||
raise RuntimeError(f"App {app} not handled (not github, gitlab or gitea with autoupdate). Upstream is {upstream}")
|
raise RuntimeError(f"App {app} not handled (not github, gitlab or gitea with autoupdate). Upstream is {upstream}")
|
||||||
|
|
||||||
|
@ -108,7 +113,7 @@ def main() -> None:
|
||||||
try:
|
try:
|
||||||
app, result = next(tasks)
|
app, result = next(tasks)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(f"Exception found: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue