blob: 8ca0c678629a923f5b280d8e677e6d3a0de64a8c [file] [log] [blame]
#! /usr/bin/env python
# Copyright 2016 WebAssembly Community Group participants
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This module is intended to be a drop-in replacement for the standard
# subprocess module, with the difference that it logs commands before it runs
# them. Everything not overriden should pass through to the subprocess module
# via the import trick below.
# Imports subprocess in its own namespace so we can always refer directly to
# its attributes.
import subprocess
# Imports all of subprocess into the current namespace, effectively re-exporting
# everything.
from subprocess import *
# Now we can override any parts of subprocess we want, while leaving the rest.
def check_call(cmd, **kwargs):
print 'check_call Running command:'
print ' '.join('"' + c + '"' if ' ' in c else c for c in cmd)
return subprocess.check_call(cmd, **kwargs)
def check_output(cmd, **kwargs):
print 'check_output Running command:'
print ' '.join('"' + c + '"' if ' ' in c else c for c in cmd)
return subprocess.check_output(cmd, **kwargs)