OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Logging related tools.""" | 6 """Logging related tools.""" |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import subprocess | 10 import subprocess |
11 import sys | 11 import sys |
(...skipping 16 matching lines...) Expand all Loading... |
28 if logging.getLogger().getEffectiveLevel() <= logging.DEBUG: | 28 if logging.getLogger().getEffectiveLevel() <= logging.DEBUG: |
29 subprocess.check_call(command, **kwargs) | 29 subprocess.check_call(command, **kwargs) |
30 else: | 30 else: |
31 p = subprocess.Popen( | 31 p = subprocess.Popen( |
32 command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) | 32 command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) |
33 p_stdout, p_stderr = p.communicate() | 33 p_stdout, p_stderr = p.communicate() |
34 if p.wait() != 0: | 34 if p.wait() != 0: |
35 sys.stdout.write(p_stdout) | 35 sys.stdout.write(p_stdout) |
36 sys.stderr.write(p_stderr) | 36 sys.stderr.write(p_stderr) |
37 raise subprocess.CalledProcessError(cmd=command, returncode=p.returncode) | 37 raise subprocess.CalledProcessError(cmd=command, returncode=p.returncode) |
OLD | NEW |