If we got fed an app url, extract the name of the app to test if we do know it

This commit is contained in:
Alexandre Aubin 2019-09-27 17:17:03 +02:00
parent c7c4d93968
commit c0e3d600b2

View file

@ -797,9 +797,19 @@ def app_install(operation_logger, app, label=None, args=None, no_remove_on_failu
raw_app_list = app_list(raw=True) raw_app_list = app_list(raw=True)
if app in raw_app_list or ('@' in app) or ('http://' in app) or ('https://' in app): if app in raw_app_list or ('@' in app) or ('http://' in app) or ('https://' in app):
# If we got an app name directly (e.g. just "wordpress"), we gonna test this name
if app in raw_app_list: if app in raw_app_list:
state = raw_app_list[app].get("state", "notworking") app_name_to_test = app
level = raw_app_list[app].get("level", None) # If we got an url like "https://github.com/foo/bar_ynh, we want to
# extract "bar" and test if we know this app
elif ('http://' in app) or ('https://' in app):
app_name_to_test = app.strip("/").split("/")[-1].replace("_ynh","")
if app_name_to_test in raw_app_list:
state = raw_app_list[app_name_to_test].get("state", "notworking")
level = raw_app_list[app_name_to_test].get("level", None)
confirm = "danger" confirm = "danger"
if state in ["working", "validated"]: if state in ["working", "validated"]:
if isinstance(level, int) and level >= 3: if isinstance(level, int) and level >= 3: