Print time of long running hook actions
We can use this to evaluate the usefulness of making hooks run in parallel.
Review URL: https://chromiumcodereview.appspot.com/18851005
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@211446 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index d86f23c..80e2b20 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -7,6 +7,7 @@
import codecs
import logging
import os
+import pipes
import Queue
import re
import stat
@@ -182,6 +183,11 @@
raise
+def CommandToStr(args):
+ """Converts an arg list into a shell escaped string."""
+ return ' '.join(pipes.quote(arg) for arg in args)
+
+
def CheckCallAndFilterAndHeader(args, always=False, header=None, **kwargs):
"""Adds 'header' support to CheckCallAndFilter.
@@ -192,7 +198,7 @@
stdout = kwargs.setdefault('stdout', sys.stdout)
if header is None:
header = "\n________ running '%s' in '%s'\n" % (
- ' '.join(args), kwargs.get('cwd', '.'))
+ CommandToStr(args), kwargs.get('cwd', '.'))
if always:
stdout.write(header)