From dd608baec5dfa79265dcf2d8a2f9d5efd9ed96ec Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 16 May 2020 00:07:35 +0200 Subject: [PATCH] Small simplification? --- src/yunohost/service.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/yunohost/service.py b/src/yunohost/service.py index ddf34c9d0..4376ee6d3 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -286,26 +286,19 @@ def service_status(names=[]): # Filter only requested servivces services = {k: v for k, v in services.items() if k in names} - result = {} + # Remove services that aren't "real" services + # + # the historical reason is because regenconf has been hacked into the + # service part of YunoHost will in some situation we need to regenconf + # for things that aren't services + # the hack was to add fake services... + services = {k: v for k, v in services.items() if v.get("status", "") is not None} - for name, infos in services.items(): - - # this "service" isn't a service actually so we skip it - # - # the historical reason is because regenconf has been hacked into the - # service part of YunoHost will in some situation we need to regenconf - # for things that aren't services - # the hack was to add fake services... - # we need to extract regenconf from service at some point, also because - # some app would really like to use it - if infos.get("status", "") is None: - continue - - result[name] = _get_and_format_service_status(name, infos) + output = {s: _get_and_format_service_status(s, infos) for s, infos in services.items()} if len(names) == 1: - return result[names[0]] - return result + return output[names[0]] + return output def _get_service_information_from_systemd(service):