Skip to content

Commit

Permalink
For JSON output, actually write JSON, not python representation.
Browse files Browse the repository at this point in the history
  • Loading branch information
alaniwi committed Nov 30, 2023
1 parent ada769f commit 52b2bba
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 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 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 52b2bba

Please sign in to comment.