示例#1
0
def status_study(args):
    """Check and print the status of an executing study."""
    study_path = args.directory
    stat_path = os.path.join(study_path, "status.csv")
    lock_path = os.path.join(study_path, ".status.lock")
    if os.path.exists(stat_path):
        lock = FileLock(lock_path)
        try:
            with lock.acquire(timeout=10):
                with open(stat_path, "r") as stat_file:
                    _ = csvtable_to_dict(stat_file)
                    print(tabulate.tabulate(_, headers="keys"))
        except Timeout:
            pass

    return 0
示例#2
0
    def get_status(cls, output_path):
        """
        Retrieve the status of the study rooted at 'out_path'.

        :param out_path: A string containing the patht to a study root.
        :returns: A dictionary containing the status of the study.
        """
        stat_path = os.path.join(output_path, "status.csv")
        lock_path = os.path.join(output_path, ".status.lock")
        _ = {}
        if os.path.exists(stat_path):
            lock = FileLock(lock_path)
            try:
                with lock.acquire(timeout=10):
                    with open(stat_path, "r") as stat_file:
                        _ = csvtable_to_dict(stat_file)
            except Timeout:
                pass

        return _