From 7da60a6aec78802462c1a11b9512fd781ef4bf59 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 2 Oct 2015 15:23:12 -0400 Subject: [PATCH 1/5] Add an app_debug function --- data/actionsmap/yunohost.yml | 8 ++++++++ lib/yunohost/app.py | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 546f7b504..f8ed8f153 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -499,6 +499,14 @@ app: full: --sql help: Initial SQL file + ### app_debug() + debug: + action_help: Display all debug informations for an application + api: GET /apps//debug + arguments: + app: + help: App name + ### app_makedefault() makedefault: action_help: Redirect domain root to an app diff --git a/lib/yunohost/app.py b/lib/yunohost/app.py index 3376a7aad..d4fb7f5d1 100644 --- a/lib/yunohost/app.py +++ b/lib/yunohost/app.py @@ -722,6 +722,19 @@ def app_clearaccess(auth, apps): app_ssowatconf(auth) +def app_debug(app): + with open(apps_setting_path + app + '/manifest.json') as f: + manifest = json.loads(f.read()) + + return { + 'name': manifest['name'], + 'services_logs': [{ + 'service': x, + 'log': service_log(x), + } for x in manifest.get("services", [])] + } + + def app_makedefault(auth, app, domain=None): """ Redirect domain root to an app From aed11d921261a8e7a207a23b377be968575c316e Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 2 Oct 2015 16:15:01 -0400 Subject: [PATCH 2/5] Fix: missing import --- lib/yunohost/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/yunohost/app.py b/lib/yunohost/app.py index d4fb7f5d1..338555df9 100644 --- a/lib/yunohost/app.py +++ b/lib/yunohost/app.py @@ -39,6 +39,8 @@ import subprocess from moulinette.core import MoulinetteError from moulinette.utils.log import getActionLogger +from .service import service_log + logger = getActionLogger('yunohost.app') repo_path = '/var/cache/yunohost/repo' From fd81c0950d0a175b53da9fbd589635de6ecad41c Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 2 Oct 2015 16:19:37 -0400 Subject: [PATCH 3/5] Simplify app debug json structure --- lib/yunohost/app.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/yunohost/app.py b/lib/yunohost/app.py index 338555df9..f18b45f9f 100644 --- a/lib/yunohost/app.py +++ b/lib/yunohost/app.py @@ -731,9 +731,8 @@ def app_debug(app): return { 'name': manifest['name'], 'services_logs': [{ - 'service': x, - 'log': service_log(x), - } for x in manifest.get("services", [])] + x: service_log(x), + } for x in sorted(manifest.get("services", []))] } From e7fd25c82e97df69c1ced2d82dfb6ae393ab4303 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 2 Oct 2015 21:15:33 -0400 Subject: [PATCH 4/5] [mod] mustache is a bit stupid, modify js to match its lameness --- lib/yunohost/app.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/yunohost/app.py b/lib/yunohost/app.py index f18b45f9f..6a38d8420 100644 --- a/lib/yunohost/app.py +++ b/lib/yunohost/app.py @@ -729,9 +729,14 @@ def app_debug(app): manifest = json.loads(f.read()) return { - 'name': manifest['name'], - 'services_logs': [{ - x: service_log(x), + 'name': manifest['id'], + 'label': manifest['name'], + 'services': [{ + "name": x, + "logs": [{ + "file_name": y, + "file_content": "\n".join(z), + } for (y, z) in sorted(service_log(x).items(), key=lambda x: x[0])], } for x in sorted(manifest.get("services", []))] } From c2cd0bdc1f6a0854a9f05c8969532ca70632eb15 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 3 Oct 2015 15:57:36 -0400 Subject: [PATCH 5/5] Add docstring to app_debug --- lib/yunohost/app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/yunohost/app.py b/lib/yunohost/app.py index 6a38d8420..eabddba0b 100644 --- a/lib/yunohost/app.py +++ b/lib/yunohost/app.py @@ -725,6 +725,12 @@ def app_clearaccess(auth, apps): def app_debug(app): + """ + Display debug informations for an app + + Keyword argument: + app + """ with open(apps_setting_path + app + '/manifest.json') as f: manifest = json.loads(f.read())