From 68cac3b36c8dacffaee66ffb0a8222ab221de9f9 Mon Sep 17 00:00:00 2001 From: "sandipsamal117@gmail.com" Date: Wed, 4 Dec 2024 11:23:23 -0500 Subject: [PATCH] save retrieve response in op json file --- pacs_retrieve.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pacs_retrieve.py b/pacs_retrieve.py index ba769e7..a840b45 100644 --- a/pacs_retrieve.py +++ b/pacs_retrieve.py @@ -9,6 +9,7 @@ import json import sys import pprint +import os LOG = logger.debug @@ -22,7 +23,7 @@ ) logger.remove() logger.add(sys.stderr, format=logger_format) -__version__ = '1.0.0' +__version__ = '1.0.1' DISPLAY_TITLE = r""" _ _ _ @@ -90,9 +91,14 @@ def main(options: Namespace, inputdir: Path, outputdir: Path): directive = json.loads(options.PACSdirective) - search_response = pfdcm.retrieve_pacsfiles(directive, options.PACSurl, options.PACSname) + retrieve_response = pfdcm.retrieve_pacsfiles(directive, options.PACSurl, options.PACSname) - LOG(f"response: {pprint.pformat(search_response)}") + LOG(f"response: {pprint.pformat(retrieve_response)}") + op_json_file_path = os.path.join(options.outputdir, "retrieve_response.json") + # Open a json writer, and use the json.dumps() + # function to dump data + with open(op_json_file_path, 'w', encoding='utf-8') as jsonf: + jsonf.write(json.dumps(retrieve_response, indent=4)) if __name__ == '__main__':