Add timestamps to "compose-cli compose status" output.

(cherry picked from commit 7bcb61849d)
This commit is contained in:
Chris Lumens 2018-07-25 11:08:56 -04:00
parent 01582e227d
commit 2251c540c8

View File

@ -17,6 +17,7 @@
import logging import logging
log = logging.getLogger("composer-cli") log = logging.getLogger("composer-cli")
from datetime import datetime
import sys import sys
import json import json
@ -79,7 +80,8 @@ def compose_status(socket_path, api_version, args, show_json=False, testmode=0):
"version": compose["version"], "version": compose["version"],
"compose_type": compose["compose_type"], "compose_type": compose["compose_type"],
"image_size": compose["image_size"], "image_size": compose["image_size"],
"status": compose["queue_status"]} "status": compose["queue_status"],
"timestamp": compose["timestamp"]}
# Sort the status in a specific order # Sort the status in a specific order
def sort_status(a): def sort_status(a):
@ -117,8 +119,10 @@ def compose_status(socket_path, api_version, args, show_json=False, testmode=0):
else: else:
image_size = "" image_size = ""
print("%s %-8s %-15s %s %-16s %s" % (c["id"], c["status"], c["blueprint"], c["version"], c["compose_type"], dt = datetime.fromtimestamp(c["timestamp"])
image_size))
print("%s %-8s %s %-15s %s %-16s %s" % (c["id"], c["status"], dt.strftime("%c"), c["blueprint"],
c["version"], c["compose_type"], image_size))
def compose_types(socket_path, api_version, args, show_json=False, testmode=0): def compose_types(socket_path, api_version, args, show_json=False, testmode=0):