[#901] Human readable date

This commit is contained in:
Andrea PIERRÉ 2018-10-05 12:54:33 +02:00 committed by Andrea Pierré
parent cedaaa9087
commit b7c8ab541f
2 changed files with 18 additions and 1 deletions

View file

@ -469,6 +469,11 @@ app:
listlists: listlists:
action_help: List registered application lists action_help: List registered application lists
api: GET /appslists api: GET /appslists
arguments:
-H:
full: --human-readable
help: Return the lastUpdate with a human readable date
action: store_true
### app_removelist() ### app_removelist()
removelist: removelist:

View file

@ -36,6 +36,7 @@ import glob
import pwd import pwd
import grp import grp
from collections import OrderedDict from collections import OrderedDict
import datetime
from moulinette import msignals, m18n, msettings from moulinette import msignals, m18n, msettings
from moulinette.core import MoulinetteError 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 List fetched lists
Keyword argument:
human_readable -- Show human readable dates
""" """
# Migrate appslist system if needed # Migrate appslist system if needed
@ -80,6 +84,14 @@ def app_listlists():
# Get the list # Get the list
appslist_list = _read_appslist_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 return appslist_list