#!/usr/bin/python3 # ==================================================== # First, compile: python setup.py build_ext --inplace # Second, exucute: python test_wrapper_flipro.py # ==================================================== # ==================================================== # ==================================================== # === Import the extension and manage errors # ==================================================== # ==================================================== try: import wrapper_flipro except Exception as e: print(f"Error import wrapper_flipropro: {e}") print("\nI try to help you to find the solution:") import os, glob import subprocess cwd = os.getcwd() fics = glob.glob("wrapper_flipro*.so") for fic in fics: cmd = f"ldd {fic}" print(f"\nExecute: {cmd}") argus = [] argus.append("ldd") argus.append(fic) res = subprocess.run(argus, capture_output=True) outb = res.stdout outs = outb.decode().split("\n") comment = "" for out in outs: print(out) words = out.split() if len(words) > 2: lib = words[0] path = words[2] if path == "not": comment = f"The path of the library {lib} is not found. Try:" if comment != "": print(f"{comment}") cmd = f"export LD_LIBRARY_PATH={cwd}:$LD_LIBRARY_PATH" print(f"$ {cmd}") print("\nIf it a success you have to record the LD_LIBRARY_PATH permanently:") print("$ sudo vi /etc/ld.so.conf") print("$ sudo ldconfig") print("") exit() # ==================================================== # ==================================================== # === List of tests to execute # ==================================================== # ==================================================== tests = [] #tests.append("matrix") tests.append("date") tests.append("one_shot") # ==================================================== # ==================================================== # === Code of tests # ==================================================== # ==================================================== import time for test in tests: print("="*40+"\n"+"="*10+f" Test: {test} \n"+"="*40) if test == "matrix": res = wrapper_flipro.matrix(4096,4096,8.99) print(f"{res=}") res = wrapper_flipro.matrix(10,5,4.56) print(f"{res=}") if test == "date": res = wrapper_flipro.date() print(f"{res=}") if test == "one_shot": try: print("== init") wrapper_flipro.init() print("== flicapabilities") res = wrapper_flipro.flicapabilities() for key, val in res.items(): print(f"{key} = {val}") print("== deviceinfo") res = wrapper_flipro.deviceinfo() for key, val in res.items(): print(f"{key} = {val}") print("== start_exp") wrapper_flipro.exptime(15) wrapper_flipro.bin((1,1)) wrapper_flipro.start_exp() import time timer = wrapper_flipro.timer() print(f"{timer=}") while timer >= 0: time.sleep(1) timer = wrapper_flipro.timer() print(f"{timer=:.2f}") print("== read_ccd") matrix, header = wrapper_flipro.read_ccd() print(f"{matrix=}") for re in header: print(f"{re=}") print("== close") wrapper_flipro.close() except BaseException as e: print("Error:", str(e)) time.sleep(1) print("== END")