From 5eb1ad953bab89d460240f04a46ef0d42dc55ec6 Mon Sep 17 00:00:00 2001 From: meejah Date: Sun, 4 Oct 2020 17:35:02 -0600 Subject: [PATCH] fix 'admin add-grid-manager-cert' --- src/allmydata/scripts/admin.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/allmydata/scripts/admin.py b/src/allmydata/scripts/admin.py index 96c1aa916..57cac39c7 100644 --- a/src/allmydata/scripts/admin.py +++ b/src/allmydata/scripts/admin.py @@ -7,6 +7,9 @@ from os.path import exists, join from twisted.python import usage #from allmydata.node import read_config from allmydata.client import read_config +from allmydata.storage_client import ( + parse_grid_manager_data, +) from allmydata.scripts.cli import _default_nodedir from allmydata.scripts.common import BaseOptions from allmydata.util.encodingutil import argv_to_abspath @@ -82,15 +85,16 @@ class AddGridManagerCertOptions(BaseOptions): raise usage.UsageError( "Reading certificate from stdin failed" ) - from allmydata.storage_client import parse_grid_manager_data - try: - self.certificate_data = parse_grid_manager_data(data) - except ValueError as e: - print("Error parsing certificate: {}".format(e), file=self.parent.parent.stderr) - self.certificate_data = None else: with open(self['filename'], 'r') as f: - self.certificate_data = f.read() + data = f.read() + + try: + self.certificate_data = parse_grid_manager_data(data) + except ValueError as e: + raise UsageError( + "Error parsing certificate: {}".format(e) + ) def getUsage(self, width=None): t = BaseOptions.getUsage(self, width)