diff --git a/buildtools/ensure_gn_version.py b/buildtools/ensure_gn_version.py index f330c1f951339a..acb1c1ddf046fd 100755 --- a/buildtools/ensure_gn_version.py +++ b/buildtools/ensure_gn_version.py @@ -18,6 +18,7 @@ from __future__ import print_function import argparse +import errno import io import os import re @@ -67,14 +68,22 @@ def main(): except subprocess.CalledProcessError as e: print('`%s` returned %d:\n%s' % (cmd_str, e.returncode, e.output)) return 1 + except OSError as e: + if e.errno != errno.ENOENT: + print('`%s` failed:\n%s' % (cmd_str, e)) + return 1 + + # The tool doesn't exist, so redownload it. + out = '' except Exception as e: print('`%s` failed:\n%s' % (cmd_str, e)) return 1 - current_revision = re.findall(r'\((.*)\)', out)[0] - if desired_revision.startswith(current_revision): - # We're on the right version, so we're done. - return 0 + if out: + current_revision = re.findall(r'\((.*)\)', out)[0] + if desired_revision.startswith(current_revision): + # We're on the right version, so we're done. + return 0 print("`%s` returned '%s', which wasn't what we were expecting." % (cmd_str, out.strip()))