~ubuntu-branches/ubuntu/saucy/cloud-init/saucy-proposed

« back to all changes in this revision

Viewing changes to cloudinit/util.py

  • Committer: Package Import Robot
  • Author(s): Scott Moser
  • Date: 2013-08-14 21:44:22 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20130814214422-uzrq82t5srz2g4c2
Tags: 0.7.3~bzr858-0ubuntu1
* New upstream snapshot.
  * fix resizing of root partition by preferring the functional 'growpart'
    support over the broken 'parted resizepart' support (LP: #1212444)
  * add options for apt_ftp_proxy, apt_https_proxy and apt_config
    (LP: #1057195)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1770
1770
                return exe_file
1771
1771
 
1772
1772
    return None
 
1773
 
 
1774
 
 
1775
def log_time(logfunc, msg, func, args=None, kwargs=None, get_uptime=False):
 
1776
    if args is None:
 
1777
        args = []
 
1778
    if kwargs is None:
 
1779
        kwargs = {}
 
1780
 
 
1781
    start = time.time()
 
1782
 
 
1783
    ustart = None
 
1784
    if get_uptime:
 
1785
        try:
 
1786
            ustart = float(uptime())
 
1787
        except ValueError:
 
1788
            pass
 
1789
 
 
1790
    try:
 
1791
        ret = func(*args, **kwargs)
 
1792
    finally:
 
1793
        delta = time.time() - start
 
1794
        if ustart is not None:
 
1795
            try:
 
1796
                udelta = float(uptime()) - ustart
 
1797
            except ValueError:
 
1798
                udelta = "N/A"
 
1799
 
 
1800
        tmsg = " took %0.3f seconds" % delta
 
1801
        if get_uptime:
 
1802
            tmsg += "(%0.2f)" % udelta
 
1803
        try:
 
1804
            logfunc(msg + tmsg)
 
1805
        except:
 
1806
            pass
 
1807
    return ret