Mercurial > repos > siwaa > erecord_file
comparison main_file.py @ 9:21b334392530 draft default tip
planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit c3cff9470de2b6b133d30faefbc0521f458a30d7-dirty
author | siwaa |
---|---|
date | Thu, 15 Feb 2024 17:37:47 +0000 |
parents | b4601b7cf763 |
children |
comparison
equal
deleted
inserted
replaced
8:b4601b7cf763 | 9:21b334392530 |
---|---|
38 | 38 |
39 MAIN_DEBUG=False # True for more information returned | 39 MAIN_DEBUG=False # True for more information returned |
40 | 40 |
41 import argparse | 41 import argparse |
42 import json | 42 import json |
43 | |
44 import erecord.api.erecord as erecord_api | 43 import erecord.api.erecord as erecord_api |
45 from erecord.api.erecord import initt | |
46 from erecord.api.erecord import conf | |
47 from erecord.api.erecord import action | |
48 from erecord.api.erecord import error_case | |
49 | |
50 from erecord.api.cmn.views_mixins import ActionViewMixin | 44 from erecord.api.cmn.views_mixins import ActionViewMixin |
51 from erecord.api.cmn.utils.errors import build_error_content | 45 from erecord.api.cmn.utils.errors import build_error_content |
52 | 46 |
53 import os | 47 import os |
54 import shutil | 48 import shutil |
63 | 57 |
64 data = dict() | 58 data = dict() |
65 json_response = dict() | 59 json_response = dict() |
66 | 60 |
67 # default configuration + maybe some modifications | 61 # default configuration + maybe some modifications |
68 config = conf() ## erecord_api.conf() # default (vle-2.0.0 version) | 62 config = erecord_api.conf() # default (vle-2.0.0 version) |
69 config.DB_add_vpz(vpz_id=1312, vpzname="wwdm.vpz", pkgname="wwdm") | 63 config.DB_add_vpz(vpz_id=1312, vpzname="wwdm.vpz", pkgname="wwdm") |
70 | 64 |
71 try : | 65 try : |
72 parser = argparse.ArgumentParser() | 66 parser = argparse.ArgumentParser() |
73 | 67 |
121 r["data"] = data | 115 r["data"] = data |
122 | 116 |
123 # configuration | 117 # configuration |
124 if MAIN_DEBUG: r["config"] = config.get_as_dict() # debug | 118 if MAIN_DEBUG: r["config"] = config.get_as_dict() # debug |
125 | 119 |
126 r_init = init(config) ## erecord_api.init(config) | 120 r_init = erecord_api.init(config) |
127 if MAIN_DEBUG: r["init"] = r_init # debug | 121 if MAIN_DEBUG: r["init"] = r_init # debug |
128 | 122 |
129 response = action(config, data) ## erecord_api.action(config, data) | 123 response = erecord_api.action(config, data) |
130 json_response = json.loads(response) | 124 json_response = json.loads(response) |
131 | 125 |
132 # Restitution : file (experiment.xls, conditions.xls, report.zip) | 126 # Restitution : file (experiment.xls, conditions.xls, report.zip) |
133 # Note : | 127 # Note : |
134 # tool.xml command "touch" the file (in case of failed to be copied here) | 128 # tool.xml command "touch" the file (in case of failed to be copied here) |
156 cnt = build_error_content(exception=e, errormsg=msg) | 150 cnt = build_error_content(exception=e, errormsg=msg) |
157 json_response["error PLUS"] = str(cnt) | 151 json_response["error PLUS"] = str(cnt) |
158 | 152 |
159 except Exception as e : | 153 except Exception as e : |
160 | 154 |
161 response = error_case(data=data, msg=PM, e=e) ## erecord_api.error_case(data=data, msg=PM, e=e) | 155 response = erecord_api.error_case(data=data, msg=PM, e=e) |
162 json_response = json.loads(response) | 156 json_response = json.loads(response) |
163 | 157 |
164 r["response"] = json_response | 158 r["response"] = json_response |
165 | 159 |
166 try : | 160 try : |