import os
import time

import lyse


def get_pid():
    with open("living_plot.ini", 'r') as pid_file:
        pid_str = pid_file.readline()

    return pid_str


def call_living_plot():
    pid_str = get_pid()
    if pid_str == "":
        start_dire = r"living_plot_main.py"
        os.popen("python %s" % start_dire)


def update_h5_path_file():
    h5_paths = lyse.h5_paths()

    with open('h5_file_path.ini', 'w') as h5_path_file:
        h5_path_file.truncate(0)
        s = '\n'.join(h5_paths)
        h5_path_file.write(s)

update_h5_path_file()
call_living_plot()

