From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C8BF713835A for ; Sat, 16 May 2020 06:43:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C957FE09A1; Sat, 16 May 2020 06:43:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ACE21E09A1 for ; Sat, 16 May 2020 06:43:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 81EAE34F0A0 for ; Sat, 16 May 2020 06:43:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 92A0724E for ; Sat, 16 May 2020 06:43:34 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1589513996.bf0244110fea5c612903629194581be42983681d.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/targets/snapshot.py X-VCS-Directories: catalyst/targets/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: bf0244110fea5c612903629194581be42983681d X-VCS-Branch: master Date: Sat, 16 May 2020 06:43:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 90edffc5-cafc-44c9-a0a5-28fc69c76169 X-Archives-Hash: 20dab3754b0565ca2e6f8108cbe857d7 commit: bf0244110fea5c612903629194581be42983681d Author: Matt Turner gentoo org> AuthorDate: Fri May 15 01:20:59 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Fri May 15 03:39:56 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=bf024411 catalyst: Add error checking to snapshot target Signed-off-by: Matt Turner gentoo.org> catalyst/targets/snapshot.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py index b6c72c51..497b2918 100644 --- a/catalyst/targets/snapshot.py +++ b/catalyst/targets/snapshot.py @@ -10,7 +10,7 @@ from pathlib import Path from catalyst import log from catalyst.base.targetbase import TargetBase from catalyst.lock import write_lock -from catalyst.support import command +from catalyst.support import CatalystError, command class snapshot(TargetBase): """ @@ -52,17 +52,27 @@ class snapshot(TargetBase): repouri, self.gitdir], ] - for cmd in git_cmds: - log.notice('>>> ' + ' '.join(cmd)) - subprocess.run(cmd, - encoding='utf-8', - close_fds=False) - - sp = subprocess.run([self.git, '-C', self.gitdir, 'rev-parse', 'stable'], - stdout=subprocess.PIPE, - encoding='utf-8', - close_fds=False) - return sp.stdout.rstrip() + try: + for cmd in git_cmds: + log.notice('>>> ' + ' '.join(cmd)) + subprocess.run(cmd, + capture_output=True, + check=True, + encoding='utf-8', + close_fds=False) + + sp = subprocess.run([self.git, '-C', self.gitdir, 'rev-parse', 'stable'], + stdout=subprocess.PIPE, + capture_output=True, + check=True, + encoding='utf-8', + close_fds=False) + return sp.stdout.rstrip() + + except subprocess.CalledProcessError as e: + raise CatalystError(f'{e.cmd} failed with return code' + f'{e.returncode}\n' + f'{e.output}\n') def run(self): if self.settings['snapshot_treeish'] == 'stable':