Change the way subprocess exceptions are caught and displayed.

This commit is contained in:
voussoir 2020-10-08 10:14:34 -07:00
parent c4670157c5
commit 779802b83e

View file

@ -133,7 +133,6 @@ def write_directories_file(directories):
with handle: with handle:
handle.write('\n'.join(directories)) handle.write('\n'.join(directories))
# GIT FUNCTIONS # GIT FUNCTIONS
################################################################################ ################################################################################
def git_commits_between(a, b): def git_commits_between(a, b):
@ -239,11 +238,8 @@ def gitcheckup(directory, do_fetch=False, do_pull=False, do_push=False):
if do_push: if do_push:
git_push() git_push()
try:
commit_details = checkup_committed() commit_details = checkup_committed()
push_details = checkup_pushed() push_details = checkup_pushed()
except subprocess.CalledProcessError as exc:
raise Exception(exc.output)
committed = 'C' if commit_details.committed else ' ' committed = 'C' if commit_details.committed else ' '
pushed = 'P' if push_details.pushed else ' ' pushed = 'P' if push_details.pushed else ' '
@ -282,8 +278,13 @@ def gitcheckup_argparse(args):
else: else:
directories = read_directories_file() directories = read_directories_file()
try:
for directory in directories: for directory in directories:
gitcheckup(directory, do_fetch=args.do_fetch, do_pull=args.do_pull, do_push=args.do_push) gitcheckup(directory, do_fetch=args.do_fetch, do_pull=args.do_pull, do_push=args.do_push)
except subprocess.CalledProcessError as exc:
sys.stdout.write(f'{exc.cmd} exited with status {exc.returncode}\n')
sys.stdout.write(exc.output.decode())
return 1
def main(argv): def main(argv):
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)