From a3167215c45ce187153a2cf8c0c2692f13ce5256 Mon Sep 17 00:00:00 2001 From: "Daniel M. Drucker" Date: Tue, 13 Feb 2024 16:20:07 -0500 Subject: [PATCH] friendlier errors --- iris/iris-get.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/iris/iris-get.py b/iris/iris-get.py index 9549d9c..3c565fa 100755 --- a/iris/iris-get.py +++ b/iris/iris-get.py @@ -61,8 +61,10 @@ if args.authfile: cmd.insert(1, "--alias") cmd.insert(2, "iris") - ret = subprocess.call( - cmd, + cp = subprocess.run( + args=cmd, + capture_output=True, + text=True, env=dict( os.environ, XNAT_PASS=password, @@ -70,5 +72,9 @@ XNAT_HOST="https://iris.mclean.harvard.edu", ), ) - if ret != 0: - raise RuntimeError('ArcGet.py call failed.') + if cp.returncode != 0: + if '401' in cp.stderr: + print("\n\033[1m * \n * Your Iris username or password is incorrect.\n *\n\033[0m") + if 'NoExperimentsError' in cp.stderr: + print("\n\033[1m * \n * The accession number you requested was not found\n * or is not available to you.\n *\n\033[0m") + print('ArcGet.py call failed: ' + cp.stderr.split("\n")[-2])