Updating FTC 2001, 10, 1 series tests to support a1pms V3 image
[nonrtric.git] / test / common / extract_sdnc_reply.py
index cb80e5e..5e37aa2 100644 (file)
@@ -20,20 +20,24 @@ import json
 import sys
 
 # Extract the response code and optional response message body from and SDNC A1 Controller API reply
-
+# Args: <json-output-key> <file-containing-the response>
 try:
-    with open(sys.argv[1]) as json_file:
+    with open(sys.argv[2]) as json_file:
         reply = json.load(json_file)
 
-        output=reply['output']
+        output=reply[sys.argv[1]]
         status=str(output['http-status'])
         while(len(status) < 3):
             status="0"+status
         resp=status
         if ( 'body' in output.keys()):
             body=str(output['body'])
-            bodyJson=json.loads(body)
-            resp=str(json.dumps(bodyJson))+str(status)
+            try:
+                bodyJson=json.loads(body)
+                resp=str(json.dumps(bodyJson))+str(status)
+            except Exception as e1:
+                resp=body+str(status)
+
         print(resp)
 
 except Exception as e: