From 0596c47e37a2aeaa39a3c0fbcbcdd8861b626ae8 Mon Sep 17 00:00:00 2001 From: sfop Date: Wed, 15 Mar 2017 13:29:02 +0100 Subject: [PATCH] Script execution --- script/local.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/script/local.py b/script/local.py index 6a16db7..7924849 100755 --- a/script/local.py +++ b/script/local.py @@ -1,7 +1,7 @@ ################################################################################################### # Deployment specific global definitions - executed after startup.py ################################################################################################### - + from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list, Gaussian from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator @@ -273,11 +273,25 @@ if get_context().isServerEnabled(): def is_camtool_running(): return int(exec_cmd("pgrep cam_server | wc -l")) > 0 +def kill_camtool(): + return exec_cmd("killall -9 cam_server") + def run_camtool(): + try: + cmd = "source /opt/gfa/python\n" + cmd = cmd + "cam_server -p 10000 -b /afs/psi.ch/intranet/SF/Applications/config/camtool_n > /dev/null &" + print exec_cmd(cmd) + except: + import traceback + print >> sys.stderr, traceback.format_exc() + +def check_camtool(): if is_camtool_running(): - return None - cmd = "source /opt/gfa/python\n" - cmd = cmd + "cam_server -p 10000 -b /afs/psi.ch/intranet/SF/Applications/config/camtool_n &" - return exec_cmd(cmd) - + return False + fork(run_camtool) + start =time.time() + while not is_camtool_running(): + if time.time() - start > 2.0: + raise Exception("Error starting camtool process") + time.sleep(0.1)