summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-02-15 12:39:10 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-02-15 12:39:10 -0800
commit2f67cdaf10a3e64474f7ac242518fdfe93e9c87a (patch)
treeb7a5e7eb6f44aee19b81b285fa9c22962eae6838 /lib
parentd1e03329c5c16ba38b082c3473e7c6970f168990 (diff)
downloadspack-2f67cdaf10a3e64474f7ac242518fdfe93e9c87a.tar.gz
spack-2f67cdaf10a3e64474f7ac242518fdfe93e9c87a.tar.bz2
spack-2f67cdaf10a3e64474f7ac242518fdfe93e9c87a.tar.xz
spack-2f67cdaf10a3e64474f7ac242518fdfe93e9c87a.zip
Better time output on build completion.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/package.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index a624c1ebf5..c48816cb5b 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -848,8 +848,8 @@ class Package(object):
build_time = self._total_time - self._fetch_time
tty.msg("Successfully installed %s." % self.name,
- "Fetch: %.2f sec. Build: %.2f sec. Total: %.2f sec."
- % (self._fetch_time, build_time, self._total_time))
+ "Fetch: %s. Build: %s. Total: %s."
+ % (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time)))
print_pkg(self.prefix)
# Use os._exit here to avoid raising a SystemExit exception,
@@ -1201,6 +1201,18 @@ def print_pkg(message):
print message
+def _hms(seconds):
+ """Convert time in seconds to hours, minutes, seconds."""
+ m, s = divmod(seconds, 60)
+ h, m = divmod(m, 60)
+
+ parts = []
+ if h: parts.append("%dh" % h)
+ if m: parts.append("%dm" % m)
+ if s: parts.append("%.2fs" % s)
+ return ' '.join(parts)
+
+
class FetchError(spack.error.SpackError):
"""Raised when something goes wrong during fetch."""
def __init__(self, message, long_msg=None):