Skip to content
Snippets Groups Projects
Commit 71728e39 authored by Matthieu Gonnet's avatar Matthieu Gonnet Committed by Seblu
Browse files

Add time command

parent 80c6bf0f
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
#coding=utf8
'''
CloudControl time command
'''
import time as systime
import datetime
from cccli.exception import *
from sjrpc.core.exceptions import *
from cccli.printer import Printer, color
from cccli.command import Command
class Command_time(Command):
'''Show execution time'''
def __init__(self, cli, argv0):
Command.__init__(self, cli, argv0)
def __call__(self, argv):
if len(argv) > 1:
# Substitute aliases
self.args = self.cli.aliases.substitute(argv[1:])
# Init time
t0 = systime.time()
# Execute command
self.cli.commands(self.args)
t1 = systime.time()
# Get elapsed time
dt = int(t1 - t0)
print "Execution time: %s" % datetime.timedelta(seconds=dt)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment