Skip to content

Commit dc8185f

Browse files
vapierLUCI
authored and
LUCI
committed
launcher: change RunError to subprocess.CalledProcessError
Since we require Python 3.6 now in the launcher, swap out our custom RunError class for the standard subprocess one. Change-Id: Id0ca17c40e22ece03e06366a263ad340963f979d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/464401 Commit-Queue: Mike Frysinger <[email protected]> Reviewed-by: Scott Lee <[email protected]> Tested-by: Mike Frysinger <[email protected]>
1 parent 59b81c8 commit dc8185f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

repo

+5-8
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,6 @@ def InitParser(parser):
482482
return parser
483483

484484

485-
# This is a poor replacement for subprocess.run until we require Python 3.6+.
486-
class RunError(Exception):
487-
"""Error when running a command failed."""
488-
489-
490485
def run_command(cmd, **kwargs):
491486
"""Run |cmd| and return its output."""
492487
check = kwargs.pop("check", False)
@@ -544,7 +539,8 @@ def run_command(cmd, **kwargs):
544539

545540
_print_output("stdout", ret.stdout)
546541
_print_output("stderr", ret.stderr)
547-
raise RunError(ret)
542+
# This will raise subprocess.CalledProcessError for us.
543+
ret.check_returncode()
548544

549545
return ret
550546

@@ -668,7 +664,7 @@ def run_git(*args, **kwargs):
668664
file=sys.stderr,
669665
)
670666
sys.exit(1)
671-
except RunError:
667+
except subprocess.CalledProcessError:
672668
raise CloneFailure()
673669

674670

@@ -850,7 +846,8 @@ def _GetRepoConfig(name):
850846
f"repo: error: git {' '.join(cmd)} failed:\n{ret.stderr}",
851847
file=sys.stderr,
852848
)
853-
raise RunError()
849+
# This will raise subprocess.CalledProcessError for us.
850+
ret.check_returncode()
854851

855852

856853
def _InitHttp():

tests/test_wrapper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_check(self):
126126
self.wrapper.run_command(["true"], check=False)
127127
self.wrapper.run_command(["true"], check=True)
128128
self.wrapper.run_command(["false"], check=False)
129-
with self.assertRaises(self.wrapper.RunError):
129+
with self.assertRaises(subprocess.CalledProcessError):
130130
self.wrapper.run_command(["false"], check=True)
131131

132132

0 commit comments

Comments
 (0)