From c7f4a1a1574f712b0b9b4b9074b5a370e6da387d Mon Sep 17 00:00:00 2001 From: meejah Date: Fri, 6 Nov 2020 18:33:54 -0700 Subject: [PATCH] factor to use FilePath more --- src/allmydata/scripts/tahoe_grid_manager.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/allmydata/scripts/tahoe_grid_manager.py b/src/allmydata/scripts/tahoe_grid_manager.py index f84f57766..42ded3344 100644 --- a/src/allmydata/scripts/tahoe_grid_manager.py +++ b/src/allmydata/scripts/tahoe_grid_manager.py @@ -330,22 +330,15 @@ def _save_gridmanager_config(file_path, grid_manager): f.write("{}\n".format(data)) -def _load_gridmanager_config(gm_config): +def _load_gridmanager_config(fp): """ Loads a Grid Manager configuration and returns it (a dict) after validating. Exceptions if the config can't be found, or has problems. - :param gm_config str: "-" (a single dash) for stdin or a filename + :param FilePath fp: None for stdin or a path to a Grid Manager + configuration directory """ - fp = None - if gm_config.strip() != '-': - fp = FilePath(gm_config.strip()) - if not fp.exists(): - raise RuntimeError( - "No such directory '{}'".format(gm_config) - ) - if fp is None: gm = json.load(sys.stdin) else: @@ -353,7 +346,7 @@ def _load_gridmanager_config(gm_config): gm = json.load(f) try: - return _GridManager.from_config(gm, gm_config) + return _GridManager.from_config(gm, fp or "") except ValueError as e: raise usage.UsageError(str(e))