Exemplo n.º 1
0
async def main_alt():
    """
    See file doc.
    """

    cenv.init()
    cdirs.init()
    inst.init()

    #############################################
    # Search course or directory from arguments #
    #############################################
    dir_, course = coex_from_argv()
    if dir_:
        courses = get_courses_from_dir(dir_)
    elif course:
        courses = [course]
    else:
        course = select_course()
        courses = [course]

    # Process each course
    for course in courses:
        async with trio.open_nursery() as nursery:
            servint = ServerInterfaceAllStatements(nursery)
            await servint.start()
            await servint.set_statements(course)
            servint.stop()

        log.debug("Got all proof states, saving")
        # Save pkl course file
        relative_course_path = course.relative_course_path
        directory_name = relative_course_path.parent
        course_hash = hash(course.file_content)

        # search for pkl file, and compare contents
        # so that only unprocessed statements will be processed
        unprocessed_statements = []
        filename = relative_course_path.stem + '.pkl'
        course_pkl_path = directory_name.joinpath(Path(filename))

        save_objects([course], course_pkl_path)

        print("===================================")
        print_goal(course)
Exemplo n.º 2
0
                    # Quit if no more open window:
                    if not (container.chooser_window
                            or container.exercise_window):
                        log.debug("Closing d∃∀duction")
                        break
                # log.debug("Out of async for loop")
            # log.debug("Out of async with")
        finally:
            # Finally closing d∃∀duction
            if container.servint:
                await container.servint.file_invalidated.wait()
                container.servint.stop()  # Good job, buddy
                log.info("Lean server stopped!")
            if container.nursery:
                container.nursery.cancel_scope.cancel()


if __name__ == '__main__':
    log.info("Starting...")
    #################################################################
    # Init environment variables, directories, and install packages #
    #################################################################

    cenv.init()
    cdirs.init()
    inst.init()

    qtrio.run(main)
    log.debug("qtrio finished")
Exemplo n.º 3
0
async def container(nursery, exercise):  # NB: nursery is pytest-trio fixture
    cenv.init()
    cdirs.init()
    inst.init()
    container = Container(nursery, exercise)
    return container
Exemplo n.º 4
0
async def main():
    """
    See file doc.
    """

    cenv.init()
    cdirs.init()
    inst.init()

    #############################################
    # Search course or directory from arguments #
    #############################################
    dir_, course = coex_from_argv()
    if dir_:
        courses = get_courses_from_dir(dir_)
    elif course:
        courses = [course]
    else:
        course = select_course()
        courses = [course]

    # Process each course
    for course in courses:
        # Check for pkl file and, if it exists, find all unprocessed statements
        course, unprocessed_statements, course_pkl_path \
            = check_statements(course)

        if not unprocessed_statements:
            log.info("pkl fle is up_to_date with all initial_proof_states")
            # Checking
            read_data(course_pkl_path)
            continue
        else:
            log.info(f"Still {len(unprocessed_statements)} "
                     f"statements to process")

        # confirm before processing file
        print("Processing? (y/n)")
        answer = input()
        if answer == 'y':
            pass
        else:
            print('Quitting')
            return

        #########################
        # Init and start server #
        #########################
        async with trio.open_nursery() as nursery:
            servint = ServerInterface(nursery)
            await servint.start()
            try:
                log.info("Pre-processing course...")
                await get_all_proof_states(servint, course,
                                           unprocessed_statements,
                                           course_pkl_path)
            except UnicodeDecodeError:
                log.error("UnicodeDecodeError")
            finally:
                servint.stop()  # Good job, buddy
                save_objects([course], course_pkl_path)

            # Checking
            read_data(course_pkl_path)