From d028ac35b12e1baec228e1c8d940b0741af6b0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=BChnel?= Date: Mon, 18 Nov 2019 16:36:23 +0100 Subject: [PATCH] improved error handling for arc patch --- scripts/phabtalk/apply_patch.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/phabtalk/apply_patch.py b/scripts/phabtalk/apply_patch.py index c97bcfc..f17c957 100755 --- a/scripts/phabtalk/apply_patch.py +++ b/scripts/phabtalk/apply_patch.py @@ -50,7 +50,7 @@ def _git_checkout(git_hash: str): except subprocess.CalledProcessError: print('WARNING: checkout of hash failed, using master branch instead.') subprocess.check_call('git checkout master', stdout=sys.stdout, stderr=sys.stderr, - shell=True) + shell=True) print('git checkout completed.') @@ -59,10 +59,11 @@ def _apply_patch(diff_id: str, conduit_token: str, host: str): cmd = 'arc patch --nobranch --no-ansi --diff "{}" --nocommit '\ '--conduit-token "{}" --conduit-uri "{}"'.format( diff_id, conduit_token, host ) - try: - subprocess.check_call(cmd, stdout=sys.stdout, stderr=sys.stderr, shell=True) - except subprocess.CalledProcessError: - print('arc patch failed!') + result = subprocess.run(cmd, capture_output=True, stderr=subprocess.STDOUT, + shell=True, text=True) + if result.returncode != 0: + print('ERROR: arc patch failed with error code {} and message:'.format(result.returncode)) + print(result.stdout + result.stderr) raise print('Patching completed.')