diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2014-11-14 13:53:14 +0100 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2014-11-14 22:11:32 +0100 |
commit | 8e96327060d34be991f5179cd18293471236ce8d (patch) | |
tree | 1f4c48dbf64b2db89b8da10d0a3efafe49b23583 /utils_prog.py | |
parent | 49c73992902a1a3aa0fd1f44b53d6c8d5a07c0ba (diff) | |
download | clufter-8e96327060d34be991f5179cd18293471236ce8d.tar.gz clufter-8e96327060d34be991f5179cd18293471236ce8d.tar.xz clufter-8e96327060d34be991f5179cd18293471236ce8d.zip |
utils_prog: add and use "Popen with logging"
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'utils_prog.py')
-rw-r--r-- | utils_prog.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/utils_prog.py b/utils_prog.py index cfbecbf..c481cda 100644 --- a/utils_prog.py +++ b/utils_prog.py @@ -26,6 +26,8 @@ from .utils import areinstances, \ selfaware, \ tuplist +log = logging.getLogger(__name__) + # # generics @@ -182,6 +184,11 @@ def set_logging(opts): rootlog.setLevel(logging.getLevelName(opts.loglevel)) +def PopenLog(cmd, *args, **kwargs): + log.debug("Running: {0}".format(' '.join(cmd))) + return Popen(cmd, *args, **kwargs) + + class OneoffWrappedStdinPopen(object): """Singleton to watch for atmost one use of stdin in Popen context""" def __init__(self): @@ -195,7 +202,7 @@ class OneoffWrappedStdinPopen(object): # only the first '-' substituted args[args.index('-')] = '/dev/stdin' self._used |= True - return Popen(args, **kwargs) + return PopenLog(args, **kwargs) OneoffWrappedStdinPopen = OneoffWrappedStdinPopen() |