diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 3d72bb57a..20eb8a0f8 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1887,6 +1887,9 @@ diagnosis: --issues: help: Only display issues action: store_true + --share: + help: Share the logs using yunopaste + action: store_true run: action_help: Show most recents diagnosis results diff --git a/src/yunohost/diagnosis.py b/src/yunohost/diagnosis.py index 88316a15f..99a798b91 100644 --- a/src/yunohost/diagnosis.py +++ b/src/yunohost/diagnosis.py @@ -44,7 +44,7 @@ def diagnosis_list(): return {"categories": all_categories_names} -def diagnosis_show(categories=[], issues=False, full=False): +def diagnosis_show(categories=[], issues=False, full=False, share=False): # Get all the categories all_categories = _list_diagnosis_categories() @@ -81,7 +81,35 @@ def diagnosis_show(categories=[], issues=False, full=False): all_reports.append(report) - return {"reports": all_reports} + if share: + from yunohost.utils.yunopaste import yunopaste + content = _dump_human_readable_reports(all_reports) + url = yunopaste(content) + + logger.info(m18n.n("log_available_on_yunopaste", url=url)) + if msettings.get('interface') == 'api': + return {"url": url} + else: + return + else: + return {"reports": all_reports} + +def _dump_human_readable_reports(reports): + + output = "" + + for report in reports: + output += "=================================\n" + output += "{description} ({id})\n".format(**report) + output += "=================================\n\n" + for item in report["items"]: + output += "[{status}] {summary}\n".format(**item) + for detail in item.get("details", []): + output += " - " + detail + "\n" + output += "\n" + output += "\n\n" + + return(output) def diagnosis_run(categories=[], force=False):