[cit] Use subprocess2 to properly sink stdout.

This should fix the "halts mid-way" symptoms observed on linux.

R=agable@chromium.org, hinoka@chromium.org

Bug: 782543
Change-Id: Ia5254b7f8e73b5646f2782e36acc52b4772b095e
Reviewed-on: https://chromium-review.googlesource.com/865821
Reviewed-by: Ryan Tseng <hinoka@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
changes/21/865821/2
Robert Iannucci 8 years ago committed by Commit Bot
parent 2377b01e6c
commit 5d6b00fac6

@ -12,14 +12,15 @@ This tool does a two things:
* Acts as an alias to infra.git/cipd/<executable> * Acts as an alias to infra.git/cipd/<executable>
""" """
# TODO(hinoka): Use cipd/glyco instead of git/gclient. # TODO(hinoka,iannucci): Pre-pack infra tools in cipd package with vpython spec.
import argparse import argparse
import sys import sys
import os import os
import subprocess
import re import re
import subprocess2 as subprocess
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
GCLIENT = os.path.join(SCRIPT_DIR, 'gclient.py') GCLIENT = os.path.join(SCRIPT_DIR, 'gclient.py')
@ -37,7 +38,7 @@ def need_to_update(branch):
try: try:
cmd = [sys.executable, GCLIENT, 'revinfo'] cmd = [sys.executable, GCLIENT, 'revinfo']
subprocess.check_call( subprocess.check_call(
cmd, cwd=os.path.join(TARGET_DIR), stdout=subprocess.PIPE) cmd, cwd=os.path.join(TARGET_DIR), stdout=subprocess.VOID)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return True # Gclient failed, definitely need to update. return True # Gclient failed, definitely need to update.
except OSError: except OSError:
@ -50,7 +51,7 @@ def need_to_update(branch):
subprocess.check_call( subprocess.check_call(
['git', 'fetch', 'origin'], cwd=INFRA_DIR, ['git', 'fetch', 'origin'], cwd=INFRA_DIR,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout=subprocess.VOID, stderr=subprocess.STDOUT)
origin_rev = get_git_rev(INFRA_DIR, 'origin/%s' % (branch,)) origin_rev = get_git_rev(INFRA_DIR, 'origin/%s' % (branch,))
return origin_rev != local_rev return origin_rev != local_rev
@ -67,11 +68,11 @@ def ensure_infra(branch):
subprocess.check_call( subprocess.check_call(
[sys.executable, os.path.join(SCRIPT_DIR, 'fetch.py'), 'infra'], [sys.executable, os.path.join(SCRIPT_DIR, 'fetch.py'), 'infra'],
cwd=TARGET_DIR, cwd=TARGET_DIR,
stdout=subprocess.PIPE) stdout=subprocess.VOID)
subprocess.check_call( subprocess.check_call(
[sys.executable, GCLIENT, 'sync', '--revision', 'origin/%s' % (branch,)], [sys.executable, GCLIENT, 'sync', '--revision', 'origin/%s' % (branch,)],
cwd=TARGET_DIR, cwd=TARGET_DIR,
stdout=subprocess.PIPE) stdout=subprocess.VOID)
sys.stderr.write(' done.\n') sys.stderr.write(' done.\n')
sys.stderr.flush() sys.stderr.flush()

Loading…
Cancel
Save