Skip to content
Snippets Groups Projects
Commit 407c8ce7 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: call scripts via API

parent 10b876b6
No related branches found
No related tags found
2 merge requests!39Release 0.4.0,!20created draft for generic analysis method
Pipeline #16682 failed
...@@ -92,6 +92,7 @@ import subprocess ...@@ -92,6 +92,7 @@ import subprocess
import sys import sys
import caosdb as db import caosdb as db
from caosdb.utils.server_side_scripting import run_server_side_script
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -134,21 +135,23 @@ def check_referenced_script(record: db.Record): ...@@ -134,21 +135,23 @@ def check_referenced_script(record: db.Record):
def call_script(script_name, record_id): def call_script(script_name, record_id):
if script_name not in os.listdir("."): ret = run_server_side_script(script_name, record_id)
logger.warning("No script with the name '{}' is installed.".format(
script_name))
return # if script_name not in os.listdir("."):
# logger.warning("No script with the name '{}' is installed.".format(
# script_name))
# return
cmd = ["./"+script_name, str(record_id)] #cmd = ["./"+script_name, str(record_id)]
print("Running: "+" ".join(cmd)) #print("Running: "+" ".join(cmd))
logger.debug("Running: "+" ".join(cmd)) #logger.debug("Running: "+" ".join(cmd))
ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) #ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print(ret.stdout.decode()) print(ret.stdout)
print(ret.stderr.decode()) print(ret.stderr)
if ret.returncode != 0: if ret.returncode != 0:
logger.warning("Skript failed") logger.warning("Script failed")
def run(dataAnalysisRecord: db.Record): def run(dataAnalysisRecord: db.Record):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment