about summary refs log tree commit diff
path: root/gn3/commands.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-07 14:41:17 -0500
committerFrederick Muriuki Muriithi2025-04-07 14:41:17 -0500
commitbd6851177602fdbce9eec15ec2d600175242fb1f (patch)
tree5b4cfd0a172dd4c89a4baf110f09ffa610d417a6 /gn3/commands.py
parentc0c6cc4110a5fe5c11b3a6994151ac9e807417dc (diff)
downloadgenenetwork3-bd6851177602fdbce9eec15ec2d600175242fb1f.tar.gz
Split the command if its a single, non-json-parseable string.
Diffstat (limited to 'gn3/commands.py')
-rw-r--r--gn3/commands.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gn3/commands.py b/gn3/commands.py
index 38153bf..51b70c3 100644
--- a/gn3/commands.py
+++ b/gn3/commands.py
@@ -3,6 +3,7 @@ commands"""
 import os
 import sys
 import json
+import shlex
 import pickle
 import logging
 import tempfile
@@ -156,7 +157,11 @@ def run_sample_corr_cmd(method, this_trait_data, target_dataset_data):
 
 def run_cmd(cmd: str, success_codes: Tuple = (0,), env: Optional[str] = None) -> Dict:
     """Run CMD and return the CMD's status code and output as a dict"""
-    parsed_cmd = json.loads(__pk__("Attempting to parse command", cmd))
+    try:
+        parsed_cmd = json.loads(__pk__("Attempting to parse command", cmd))
+    except json.decoder.JSONDecodeError as jderr:
+        parsed_cmd = shlex.split(cmd)
+
     parsed_env = (json.loads(env) if env is not None else None)
 
     results = subprocess.run(