mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Implement diagnosis show --full and --issues
This commit is contained in:
parent
9405362caf
commit
1d8ba7fa95
2 changed files with 19 additions and 2 deletions
|
@ -1884,6 +1884,9 @@ diagnosis:
|
||||||
--full:
|
--full:
|
||||||
help: Display additional information
|
help: Display additional information
|
||||||
action: store_true
|
action: store_true
|
||||||
|
--issues:
|
||||||
|
help: Only display issues
|
||||||
|
action: store_true
|
||||||
|
|
||||||
run:
|
run:
|
||||||
action_help: Show most recents diagnosis results
|
action_help: Show most recents diagnosis results
|
||||||
|
|
|
@ -42,7 +42,7 @@ def diagnosis_list():
|
||||||
all_categories_names = [ h for h, _ in _list_diagnosis_categories() ]
|
all_categories_names = [ h for h, _ in _list_diagnosis_categories() ]
|
||||||
return { "categories": all_categories_names }
|
return { "categories": all_categories_names }
|
||||||
|
|
||||||
def diagnosis_show(categories=[], full=False):
|
def diagnosis_show(categories=[], issues=False, full=False):
|
||||||
|
|
||||||
# Get all the categories
|
# Get all the categories
|
||||||
all_categories = _list_diagnosis_categories()
|
all_categories = _list_diagnosis_categories()
|
||||||
|
@ -60,9 +60,23 @@ def diagnosis_show(categories=[], full=False):
|
||||||
all_reports = []
|
all_reports = []
|
||||||
for category in categories:
|
for category in categories:
|
||||||
try:
|
try:
|
||||||
all_reports.append(Diagnoser.get_cached_report(category))
|
cat_report = Diagnoser.get_cached_report(category)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to fetch diagnosis result for category '%s' : %s" % (category, str(e))) # FIXME : i18n
|
logger.error("Failed to fetch diagnosis result for category '%s' : %s" % (category, str(e))) # FIXME : i18n
|
||||||
|
else:
|
||||||
|
if not full:
|
||||||
|
del cat_report["timestamp"]
|
||||||
|
del cat_report["cached_for"]
|
||||||
|
for report in cat_report["reports"]:
|
||||||
|
del report["meta"]
|
||||||
|
del report["result"]
|
||||||
|
if issues:
|
||||||
|
cat_report["reports"] = [ r for r in cat_report["reports"] if r["report"][0] != "SUCCESS" ]
|
||||||
|
if not cat_report["reports"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
all_reports.append(cat_report)
|
||||||
|
|
||||||
|
|
||||||
return {"reports": all_reports}
|
return {"reports": all_reports}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue