Only print when got error for some commands.

This commit is contained in:
Cheng Zhao 2014-02-26 22:08:01 +08:00
parent 637b50044d
commit 120094a81e
4 changed files with 19 additions and 11 deletions

5
script/cpplint.py vendored
View file

@ -2,9 +2,10 @@
import fnmatch import fnmatch
import os import os
import subprocess
import sys import sys
from lib.util import execute
IGNORE_FILES = [ IGNORE_FILES = [
os.path.join('browser', 'atom_application_mac.h'), os.path.join('browser', 'atom_application_mac.h'),
os.path.join('browser', 'atom_application_delegate_mac.h'), os.path.join('browser', 'atom_application_delegate_mac.h'),
@ -44,7 +45,7 @@ def list_files(directories, filters):
def call_cpplint(files): def call_cpplint(files):
cpplint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'cpplint.py') cpplint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'cpplint.py')
rules = '--filter=-build/header_guard,-build/include_what_you_use' rules = '--filter=-build/header_guard,-build/include_what_you_use'
subprocess.check_call([sys.executable, cpplint, rules] + files) execute([sys.executable, cpplint, rules] + files)
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -9,7 +9,7 @@ import tarfile
from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, NODE_VERSION from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, NODE_VERSION
from lib.util import scoped_cwd, rm_rf, get_atom_shell_version, make_zip, \ from lib.util import scoped_cwd, rm_rf, get_atom_shell_version, make_zip, \
safe_mkdir safe_mkdir, execute
ATOM_SHELL_VRESION = get_atom_shell_version() ATOM_SHELL_VRESION = get_atom_shell_version()
@ -107,7 +107,7 @@ def parse_args():
def force_build(): def force_build():
build = os.path.join(SOURCE_ROOT, 'script', 'build.py') build = os.path.join(SOURCE_ROOT, 'script', 'build.py')
subprocess.check_call([sys.executable, build, '-c', 'Release']) execute([sys.executable, build, '-c', 'Release'])
def copy_binaries(): def copy_binaries():

View file

@ -65,7 +65,7 @@ def extract_tarball(tarball_path, member, destination):
def extract_zip(zip_path, destination): def extract_zip(zip_path, destination):
if sys.platform == 'darwin': if sys.platform == 'darwin':
# Use unzip command on Mac to keep symbol links in zip file work. # Use unzip command on Mac to keep symbol links in zip file work.
subprocess.check_output(['unzip', zip_path, '-d', destination]) execute(['unzip', zip_path, '-d', destination])
else: else:
with zipfile.ZipFile(zip_path) as z: with zipfile.ZipFile(zip_path) as z:
z.extractall(destination) z.extractall(destination)
@ -74,7 +74,7 @@ def make_zip(zip_file_path, files, dirs):
safe_unlink(zip_file_path) safe_unlink(zip_file_path)
if sys.platform == 'darwin': if sys.platform == 'darwin':
files += dirs files += dirs
subprocess.check_output(['zip', '-r', '-y', zip_file_path] + files) execute(['zip', '-r', '-y', zip_file_path] + files)
else: else:
zip_file = zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED) zip_file = zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED)
for filename in files: for filename in files:
@ -110,5 +110,13 @@ def safe_mkdir(path):
raise raise
def execute(argv):
try:
subprocess.check_output(argv, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print e.output
raise e
def get_atom_shell_version(): def get_atom_shell_version():
return subprocess.check_output(['git', 'describe', '--tags']).strip() return subprocess.check_output(['git', 'describe', '--tags']).strip()

View file

@ -9,7 +9,7 @@ import sys
import tempfile import tempfile
from lib.config import NODE_VERSION from lib.config import NODE_VERSION
from lib.util import get_atom_shell_version, scoped_cwd, safe_mkdir from lib.util import get_atom_shell_version, scoped_cwd, safe_mkdir, execute
from lib.github import GitHub from lib.github import GitHub
@ -36,7 +36,7 @@ def main():
if not dist_newer_than_head(): if not dist_newer_than_head():
create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py') create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
subprocess.check_output([sys.executable, create_dist]) execute([sys.executable, create_dist])
build_version = get_atom_shell_build_version() build_version = get_atom_shell_build_version()
if not ATOM_SHELL_VRESION.startswith(build_version): if not ATOM_SHELL_VRESION.startswith(build_version):
@ -158,8 +158,7 @@ def upload_node(bucket, access_key, secret_key, version):
if TARGET_PLATFORM == 'win32': if TARGET_PLATFORM == 'win32':
# Generate the node.lib. # Generate the node.lib.
build = os.path.join(SOURCE_ROOT, 'script', 'build.py') build = os.path.join(SOURCE_ROOT, 'script', 'build.py')
subprocess.check_output([sys.executable, build, '-c', 'Release', execute([sys.executable, build, '-c', 'Release', '-t', 'generate_node_lib'])
'-t', 'generate_node_lib'])
# Upload the 32bit node.lib. # Upload the 32bit node.lib.
node_lib = os.path.join(OUT_DIR, 'node.lib') node_lib = os.path.join(OUT_DIR, 'node.lib')
@ -203,7 +202,7 @@ def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
'--grant', 'public-read' '--grant', 'public-read'
] + files ] + files
subprocess.check_output(args) execute(args)
def touch_x64_node_lib(): def touch_x64_node_lib():