diff --git a/client/cli/bam.py b/client/cli/bam.py index 55c800e..714aa27 100755 --- a/client/cli/bam.py +++ b/client/cli/bam.py @@ -82,7 +82,7 @@ class bam_config: if filepath is None: import sys sys.stderr.write( - "fatal: Not a git repository " + "fatal: Not a bam repository " "(or any of the parent directories): .bam\n") sys.exit(1) @@ -416,7 +416,13 @@ class bam_utils: stream=True, ) - items = r.json().get("items_list", ()) + r_json = r.json() + items = r_json.get("items_list", None) + if items is None: + import sys + sys.stderr.write("fatal: %s\n" % r_json.get("message", "")) + sys.exit(1) + items.sort() for (name_short, name_full, file_type) in items: diff --git a/webservice/bam/application/__init__.py b/webservice/bam/application/__init__.py index e66ae20..5f4ea48 100644 --- a/webservice/bam/application/__init__.py +++ b/webservice/bam/application/__init__.py @@ -93,6 +93,10 @@ class DirectoryAPI(Resource): absolute_path_root = os.path.join(absolute_path_root, path) parent_path = os.pardir + + if not os.path.isdir(absolute_path_root): + return jsonify(message="Path is not a directory %r" % absolute_path_root) + items_list = [] for f in os.listdir(absolute_path_root):