mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
commit
377e74aa8e
1 changed files with 27 additions and 7 deletions
|
@ -6,6 +6,7 @@ from yunohost.app import app_list
|
||||||
|
|
||||||
from yunohost.diagnosis import Diagnoser
|
from yunohost.diagnosis import Diagnoser
|
||||||
|
|
||||||
|
|
||||||
class AppDiagnoser(Diagnoser):
|
class AppDiagnoser(Diagnoser):
|
||||||
|
|
||||||
id_ = os.path.splitext(os.path.basename(__file__))[0].split("-")[1]
|
id_ = os.path.splitext(os.path.basename(__file__))[0].split("-")[1]
|
||||||
|
@ -30,13 +31,17 @@ class AppDiagnoser(Diagnoser):
|
||||||
if not app["issues"]:
|
if not app["issues"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
level = "ERROR" if any(issue[0] == "error" for issue in app["issues"]) else "WARNING"
|
level = (
|
||||||
|
"ERROR"
|
||||||
|
if any(issue[0] == "error" for issue in app["issues"])
|
||||||
|
else "WARNING"
|
||||||
|
)
|
||||||
|
|
||||||
yield dict(
|
yield dict(
|
||||||
meta={"test": "apps", "app": app["name"]},
|
meta={"test": "apps", "app": app["name"]},
|
||||||
status=level,
|
status=level,
|
||||||
summary="diagnosis_apps_issue",
|
summary="diagnosis_apps_issue",
|
||||||
details=[issue[1] for issue in app["issues"]]
|
details=[issue[1] for issue in app["issues"]],
|
||||||
)
|
)
|
||||||
|
|
||||||
def issues(self, app):
|
def issues(self, app):
|
||||||
|
@ -45,14 +50,19 @@ class AppDiagnoser(Diagnoser):
|
||||||
|
|
||||||
if not app.get("from_catalog") or app["from_catalog"].get("state") != "working":
|
if not app.get("from_catalog") or app["from_catalog"].get("state") != "working":
|
||||||
yield ("error", "diagnosis_apps_not_in_app_catalog")
|
yield ("error", "diagnosis_apps_not_in_app_catalog")
|
||||||
elif not isinstance(app["from_catalog"].get("level"), int) or app["from_catalog"]["level"] == 0:
|
elif (
|
||||||
|
not isinstance(app["from_catalog"].get("level"), int)
|
||||||
|
or app["from_catalog"]["level"] == 0
|
||||||
|
):
|
||||||
yield ("error", "diagnosis_apps_broken")
|
yield ("error", "diagnosis_apps_broken")
|
||||||
elif app["from_catalog"]["level"] <= 4:
|
elif app["from_catalog"]["level"] <= 4:
|
||||||
yield ("warning", "diagnosis_apps_bad_quality")
|
yield ("warning", "diagnosis_apps_bad_quality")
|
||||||
|
|
||||||
# Check for super old, deprecated practices
|
# Check for super old, deprecated practices
|
||||||
|
|
||||||
yunohost_version_req = app["manifest"].get("requirements", {}).get("yunohost", "").strip(">= ")
|
yunohost_version_req = (
|
||||||
|
app["manifest"].get("requirements", {}).get("yunohost", "").strip(">= ")
|
||||||
|
)
|
||||||
if yunohost_version_req.startswith("2."):
|
if yunohost_version_req.startswith("2."):
|
||||||
yield ("error", "diagnosis_apps_outdated_ynh_requirement")
|
yield ("error", "diagnosis_apps_outdated_ynh_requirement")
|
||||||
|
|
||||||
|
@ -64,11 +74,21 @@ class AppDiagnoser(Diagnoser):
|
||||||
"yunohost tools port-available",
|
"yunohost tools port-available",
|
||||||
]
|
]
|
||||||
for deprecated_helper in deprecated_helpers:
|
for deprecated_helper in deprecated_helpers:
|
||||||
if os.system(f"grep -nr -q '{deprecated_helper}' {app['setting_path']}/scripts/") == 0:
|
if (
|
||||||
|
os.system(
|
||||||
|
f"grep -nr -q '{deprecated_helper}' {app['setting_path']}/scripts/"
|
||||||
|
)
|
||||||
|
== 0
|
||||||
|
):
|
||||||
yield ("error", "diagnosis_apps_deprecated_practices")
|
yield ("error", "diagnosis_apps_deprecated_practices")
|
||||||
|
|
||||||
old_arg_regex = r'^domain=\${?[0-9]'
|
old_arg_regex = r"^domain=\${?[0-9]"
|
||||||
if os.system(f"grep -q '{old_arg_regex}' {app['setting_path']}/scripts/install") == 0:
|
if (
|
||||||
|
os.system(
|
||||||
|
f"grep -q '{old_arg_regex}' {app['setting_path']}/scripts/install"
|
||||||
|
)
|
||||||
|
== 0
|
||||||
|
):
|
||||||
yield ("error", "diagnosis_apps_deprecated_practices")
|
yield ("error", "diagnosis_apps_deprecated_practices")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue