diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-05-28 18:53:50 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-05-28 18:55:59 +0100 |
commit | ef24fd8a8f87720f8ef400d904cbb4417acc585b (patch) | |
tree | db31e424578cb4099b09b89cbf1a56efad39839f /sandboxlib | |
parent | 698a77d97c534c2a7180bfa21aba4d6446d56ebc (diff) | |
download | sandboxlib-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__.py | 9 |
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, |