def on_change_data_path(path): if path is not None: print "Data path: " + str(path) raw_data_folder = path + "/raw_data" os.makedirs(raw_data_folder) #with open(raw_data_folder + "/test.txt", "w") as f: # f.write("Success") for name, info in DETECTORS.items(): log(name + " enabled = " + str(info["enabled"])) if info["enabled"]: channel_path = info["path"] caput_str(channel_path, raw_data_folder + "/" + name) def check_detector(name, raw_data_folder): info = DETECTORS[name] dev_path = raw_data_folder + "/" + name channel_path = info["path"] try: caget_str(channel_path) print "OK: ", name info["enabled"] = True channel_path = info["path"] caput_str(channel_path, dev_path) return name + " ok" except: print "ERROR: ", name info["enabled"] = False return name + " error" finally: log(name + " enabled = " + str(info["enabled"])+ " folder = " + str(dev_path)) def check_detectors(raw_data_folder, timeout = 0.5): functions = [] for name, info in DETECTORS.items(): functions.append((check_detector,(name,raw_data_folder))) r = fork(*functions) chrono = Chrono() while True: if not False in [f.isDone() for f in r]: break if timeout >0: if chrono.isTimeout(int(timeout*1000)): break time.sleep(0.01) r = check_detectors("/sls/X05LA/Data1/x05laop/2022_04/20220411/") log("QUit", False)