diff --git a/nlds_client/nlds_client.py b/nlds_client/nlds_client.py index 9965c15..57bafde 100755 --- a/nlds_client/nlds_client.py +++ b/nlds_client/nlds_client.py @@ -1,5 +1,7 @@ #! /usr/bin/env python import click +from json import dumps as json_dumps + from nlds_client.clientlib.transactions import (get_filelist, put_filelist, list_holding, find_file, monitor_transactions, @@ -367,7 +369,7 @@ def put(filepath, user, group, job_label, response = put_filelist([filepath], user, group, job_label, label, holding_id, tag) if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_response(response) except ConnectionError as ce: @@ -412,7 +414,7 @@ def get(filepath, user, group, target, job_label, response = get_filelist([filepath], user, group, target, job_label, label, holding_id, tag) if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_response(response) except ConnectionError as ce: @@ -465,7 +467,7 @@ def putlist(filelist, user, group, label, job_label, response = put_filelist(files, user, group, job_label, label, holding_id, tag) if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_response(response) @@ -484,7 +486,7 @@ def putlist(filelist, user, group, label, job_label, help="The username to get files for.") @click.option("-g", "--group", default=None, type=str, help="The group to get files for.") -@click.option("-t", "--target", default=None, type=click.Path(exists=True), +@click.option("-r", "--target", default=None, type=click.Path(exists=True), help="The target path for the retrieved files. Default is to " "retrieve files to their original path.") @click.option("-l", "--label", default=None, type=str, @@ -514,7 +516,7 @@ def getlist(filelist, user, group, target, job_label, response = get_filelist(files, user, group, target, job_label, label, holding_id, tag) if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_response(response) except ConnectionError as ce: @@ -554,7 +556,7 @@ def list(user, group, label, holding_id, transaction_id, tag, json): ) if response['success']: if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_list(response, req_details) else: @@ -606,7 +608,7 @@ def stat(user, group, id, transaction_id, job_label, api_action, state, json): ) if response['success']: if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_stat(response, req_details) else: @@ -655,7 +657,7 @@ def find(user, group, label, holding_id, transaction_id, path, tag, json): ) if response['success']: if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_find(response, req_details) else: @@ -704,7 +706,7 @@ def meta(user, group, label, holding_id, tag, new_label, new_tag, del_tag, json) new_label, new_tag, del_tag) if response['success'] > 0: if json: - click.echo(response) + click.echo(json_dumps(response)) else: print_meta(response, req_details) else: