Skip to content

Commit

Permalink
Merge pull request #9 from cedadev/ai_dev
Browse files Browse the repository at this point in the history
For JSON output, actually write JSON, not python representation.
  • Loading branch information
jackleland authored Dec 18, 2023
2 parents ada769f + 127c294 commit fd0ea8c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions nlds_client/nlds_client.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fd0ea8c

Please sign in to comment.