From fda269d96b123fb7636885ec094589cbcfa4bc39 Mon Sep 17 00:00:00 2001
From: chausman <chausman@nrao.edu>
Date: Fri, 16 Jul 2021 16:49:28 -0600
Subject: [PATCH] fixing aat-wrest access for restores

---
 apps/cli/utilities/aat_wrest/aat_wrest/wrest.py           | 1 -
 .../workspaces/workflow/services/workflow_service.py      | 8 ++++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/apps/cli/utilities/aat_wrest/aat_wrest/wrest.py b/apps/cli/utilities/aat_wrest/aat_wrest/wrest.py
index c85b8f35e..598e75ffe 100644
--- a/apps/cli/utilities/aat_wrest/aat_wrest/wrest.py
+++ b/apps/cli/utilities/aat_wrest/aat_wrest/wrest.py
@@ -61,7 +61,6 @@ def determine_wrester(connection: MDDBConnector, args: argparse.Namespace):
     elif args.stdimg:
         data = WrestWorkflowMetadata(connection, sdm_id=args.stdimg[0]).wrest_standard_image_info()
     elif args.restore:
-        print(args)
         data = WrestWorkflowMetadata(connection, spl=args.restore).wrest_restore_info()
     elif args.observation:
         data = WrestObservationMetadata(
diff --git a/shared/workspaces/workspaces/workflow/services/workflow_service.py b/shared/workspaces/workspaces/workflow/services/workflow_service.py
index 95e2d1983..38f58f0b9 100644
--- a/shared/workspaces/workspaces/workflow/services/workflow_service.py
+++ b/shared/workspaces/workspaces/workflow/services/workflow_service.py
@@ -235,22 +235,26 @@ class WorkflowService(WorkflowServiceIF):
         if "calibration" in name:
             wrest_type = "-sc"
             argument = wf_request.argument["product_locator"]
+            argument2 = []
         elif "restore" in name:
             wrest_type = "-r"
-            argument = [wf_request.argument["product_locator"], wf_request.argument["cal_locator"]]
+            argument = wf_request.argument["product_locator"]
+            argument2 = [wf_request.argument["cal_locator"]]
         elif "imaging" in name:
             wrest_type = "-si"
             argument = wf_request.argument["sdmId"]
+            argument2 = []
         else:
             logger.info(f"No wrester found for workflow {name}. Does it actually require metadata?")
             return wf_request
 
         logger.info(f" workflow {name} has wrest option: {wrest_type}")
         with subprocess.Popen(
-            ["aat_wrest", wrest_type, argument],
+            ["aat_wrest", wrest_type, argument] + argument2,
             stdout=subprocess.PIPE,
         ) as wf_metadata:
             wf_json = wf_metadata.communicate()[0]
+            logger.info(wf_json.decode())
             if "ERROR" not in wf_json.decode():
                 merged_args = {
                     **json.loads(wf_json),
-- 
GitLab