Пример #1
0
def remove_lock_file(_file):
    """Remove a specific lock file (not logged to locks_log.csv)"""
    locks_directory = SharedData.get_locks_directory()

    os.remove(os.path.join(locks_directory, _file))

    logger.log("lock file was removed manually", _file, logger.WARNING)
Пример #2
0
def watch_students(student_list, students, lab, use_locks):
    """Register paths when the filtered list is created"""
    paths = [
        SharedData.get_locks_directory(),
        SharedData.get_flags_directory()
    ]
    data.fs_watch.fs_watch_register(paths, "student_list_watch",
                                    fill_student_list, student_list, students,
                                    lab, use_locks, student_select_fn)
Пример #3
0
def unlock_all_labs_by_grader(username: str):
    """Remove all lock files for a given grader"""
    # Look at all lock files
    for lock in get_lock_files():
        lock_parts = lock.split(".")

        # Only look at the lock files graded by the current grader
        if lock_parts[0] == username:
            os.remove(os.path.join(SharedData.get_locks_directory(), lock))

    logger.log("All locks under the current grader were removed",
               logger.WARNING)
Пример #4
0
def get_lock_file_path(student: Student, lab: Lab = None):
    """Return path for lock file"""
    username = getpass.getuser()

    # We can safely store both lab+student and lab locks in the
    # Same directory
    if lab:
        lab_name = lab.get_unique_name()
        student_name = student.get_unique_name()
        lock_path = f"{username}.{lab_name}.{student_name}.lock"
    else:
        student_name = student.get_unique_name()
        lock_path = f"{username}.{student_name}.lock"

    return os.path.join(SharedData.get_locks_directory(), lock_path)
Пример #5
0
def unlock_all_labs():
    """Remove all locks"""
    for lock in get_lock_files():
        os.remove(os.path.join(SharedData.get_locks_directory(), lock))
Пример #6
0
def get_lock_files():
    """Return a list of all lock files"""
    return [
        l for l in os.listdir(SharedData.get_locks_directory())
        if l.endswith(".lock")
    ]