diff main_json.py @ 2:afc88ac8de69 draft

planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_json commit 2bd91617d46a1c454a7a167113cc605bdd1b3ff2-dirty
author siwaa
date Thu, 15 Feb 2024 14:44:16 +0000
parents 8a0659f23df7
children eb06af7c29a8
line wrap: on
line diff
--- a/main_json.py	Wed Dec 13 21:46:11 2023 +0000
+++ b/main_json.py	Thu Feb 15 14:44:16 2024 +0000
@@ -23,7 +23,8 @@
       available only in some cases)
 
    Outputs :
-   - output.json data file
+   - output.json data file (jsonoutput_filepath)
+
 """
 
 MAIN_DEBUG=False # True for more information returned
@@ -31,10 +32,8 @@
 import argparse
 import json
 import erecord.api.erecord as erecord_api
+
 import os
-from erecord.api.cmn.utils.dir_and_file import create_dir_if_absent
-from erecord.api.cmn.configs.config import PROJECT_HOME
-from erecord.api.cmn.configs.config import out_path
 
 PM = "[main_json.py]"
 
@@ -42,20 +41,15 @@
                    'get_vpz_report_conditions', 'post_vpz_report_conditions',
                    'get_vpz_report', 'post_vpz_report']
 
-jsonoutput_filepath = os.path.join(out_path, "output.json") # tool.xml uses it
-
 r = dict()
 
 import sys
 if MAIN_DEBUG: r["sys.path"] = sys.path # debug
 if MAIN_DEBUG: r["sys.argv"] = sys.argv # debug
-if MAIN_DEBUG: r["out_path"] = out_path # debug
 
 data = dict()
 json_response = dict()
 
-create_dir_if_absent(PROJECT_HOME) # required
-
 try :
     parser = argparse.ArgumentParser()
     parser.add_argument("-data", type=str, help="data json file path")
@@ -86,9 +80,16 @@
             data["action"] = 'help'
 
     r["data"] = data
-    r_init = erecord_api.init()
+
+    # default configuration + maybe some modifications
+    config = erecord_api.conf() # default (vle-2.0.0 version)
+    config.DB_add_vpz(vpz_id=1312, vpzname="wwdm.vpz", pkgname="wwdm")
+    if MAIN_DEBUG: r["config"] = config.get_as_dict() # debug
+
+    r_init = erecord_api.init(config)
     if MAIN_DEBUG: r["init"] = r_init # debug
-    response = erecord_api.action(data)
+
+    response = erecord_api.action(config, data)
     json_response = json.loads(response)
 
 except Exception as e :
@@ -99,6 +100,7 @@
 r["response"] = json_response
 
 # Restitution : json file
+jsonoutput_filepath = os.path.join(config.out_path, config.jsonoutput_filename)
 with open(jsonoutput_filepath, "w") as outfile:
     json.dump(r, outfile)