diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index ba5f1d505..a6bc8ec3e 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -470,6 +470,11 @@ app: listlists: action_help: List registered application lists api: GET /appslists + arguments: + -H: + full: --human-readable + help: Return the lastUpdate with a human readable date + action: store_true ### app_removelist() removelist: diff --git a/src/yunohost/app.py b/src/yunohost/app.py index e26700c49..66d83db9c 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -36,6 +36,7 @@ import glob import pwd import grp from collections import OrderedDict +import datetime from moulinette import msignals, m18n, msettings from moulinette.core import MoulinetteError @@ -66,10 +67,13 @@ re_app_instance_name = re.compile( ) -def app_listlists(): +def app_listlists(human_readable=False): """ List fetched lists + Keyword argument: + human_readable -- Show human readable dates + """ # Migrate appslist system if needed @@ -80,6 +84,14 @@ def app_listlists(): # Get the list appslist_list = _read_appslist_list() + # Human readable date + if human_readable: + for app in appslist_list: + now_for_humans = datetime.datetime.fromtimestamp( + appslist_list[app].get("lastUpdate")) + appslist_list[app]["lastUpdate"] = now_for_humans.strftime( + '%Y-%m-%d %H:%M:%S') + return appslist_list