summaryrefslogtreecommitdiff
path: root/sandboxlib
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-05-28 18:53:50 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-05-28 18:55:59 +0100
commitef24fd8a8f87720f8ef400d904cbb4417acc585b (patch)
treedb31e424578cb4099b09b89cbf1a56efad39839f /sandboxlib
parent698a77d97c534c2a7180bfa21aba4d6446d56ebc (diff)
downloadsandboxlib-ef24fd8a8f87720f8ef400d904cbb4417acc585b.tar.gz
Log the actual commandline being run
This makes it easier to debug problems. The log domain 'sandboxlib' is used, so callers can handle the log messages from 'sandboxlib' however they want using the Python 'logging' API.
Diffstat (limited to 'sandboxlib')
-rw-r--r--sandboxlib/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/sandboxlib/__init__.py b/sandboxlib/__init__.py
index 0b150d7..b4199f1 100644
--- a/sandboxlib/__init__.py
+++ b/sandboxlib/__init__.py
@@ -25,6 +25,7 @@ docstrings that describe the different parameters.
import logging
import os
import platform
+import pipes
import shutil
import subprocess
import sys
@@ -195,6 +196,11 @@ def validate_extra_mounts(extra_mounts):
return new_extra_mounts
+
+def argv_to_string(argv):
+ return ' '.join(map(pipes.quote, argv))
+
+
def _run_command(argv, stdout, stderr, cwd=None, env=None):
'''Wrapper around subprocess.Popen() with common settings.
@@ -215,6 +221,9 @@ def _run_command(argv, stdout, stderr, cwd=None, env=None):
else:
dev_null = None
+ log = logging.getLogger('sandboxlib')
+ log.debug('Running: %s', argv_to_string(argv))
+
try:
process = subprocess.Popen(
argv,