From: Matt Turner <mattst88@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Cc: Matt Turner <mattst88@gentoo.org>
Subject: [gentoo-catalyst] [PATCH 6/8] catalyst: Add error checking to snapshot target
Date: Thu, 14 May 2020 23:09:59 -0700 [thread overview]
Message-ID: <20200515061001.2581484-6-mattst88@gentoo.org> (raw)
In-Reply-To: <20200515061001.2581484-1-mattst88@gentoo.org>
Signed-off-by: Matt Turner <mattst88@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':
--
2.26.2
next prev parent reply other threads:[~2020-05-15 6:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 6:09 [gentoo-catalyst] [PATCH 1/8] doc: Remove extra asterisk Matt Turner
2020-05-15 6:09 ` [gentoo-catalyst] [PATCH 2/8] doc: Drop pre-EAPI-5 text Matt Turner
2020-05-15 6:09 ` [gentoo-catalyst] [PATCH 3/8] doc: Merge SUPPORTED HASHES section into digests section Matt Turner
2020-05-15 6:09 ` [gentoo-catalyst] [PATCH 4/8] targets: Test for locale-gen Matt Turner
2020-05-15 6:09 ` [gentoo-catalyst] [PATCH 5/8] catalyst: Drop unnecessary clear_path() Matt Turner
2020-05-15 6:09 ` Matt Turner [this message]
2020-05-15 6:10 ` [gentoo-catalyst] [PATCH 7/8] catalyst: Make parent directories of snapshots/ Matt Turner
2020-05-15 6:10 ` [gentoo-catalyst] [PATCH 8/8] catalyst: Explain the git gc config options Matt Turner
2020-05-16 1:51 ` [gentoo-catalyst] [PATCH 1/8] doc: Remove extra asterisk Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200515061001.2581484-6-mattst88@gentoo.org \
--to=mattst88@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox