changeset 3:eb06af7c29a8 draft default tip

planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_json commit 490623122691651ac91c33d75ea1898189be7512-dirty
author siwaa
date Thu, 15 Feb 2024 15:24:41 +0000
parents afc88ac8de69
children
files main_json.py
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/main_json.py	Thu Feb 15 14:44:16 2024 +0000
+++ b/main_json.py	Thu Feb 15 15:24:41 2024 +0000
@@ -24,7 +24,6 @@
 
    Outputs :
    - output.json data file (jsonoutput_filepath)
-
 """
 
 MAIN_DEBUG=False # True for more information returned
@@ -50,6 +49,10 @@
 data = dict()
 json_response = dict()
 
+# 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")
+
 try :
     parser = argparse.ArgumentParser()
     parser.add_argument("-data", type=str, help="data json file path")
@@ -81,9 +84,7 @@
 
     r["data"] = data
 
-    # 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")
+    # configuration
     if MAIN_DEBUG: r["config"] = config.get_as_dict() # debug
 
     r_init = erecord_api.init(config)
@@ -99,8 +100,13 @@
 
 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)
+try :
+    # 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)
 
+except :
+    print(PM, " -- error when trying to open output json file --")
+