예제 #1
0
def end_scene(args, scene_root, history_db, current_scene_db):
    """ends a scene"""
    from src.praxxis.sqlite import sqlite_scene
    from src.praxxis.display import display_scene
    from src.praxxis.scene import scene
    from src.praxxis.util import error

    if hasattr(args, "name"):
        # end scene can have 0 args and end the current scene
        if (args.name is None):
            name = sqlite_scene.get_current_scene(history_db)
        else:
            name = args.name
    else:
        name = args

    try:
        tmp_name = scene.get_scene_by_ordinal(args, name, history_db)
    except error.SceneNotFoundError as e:
        raise (e)

    if tmp_name is not None:
        name = tmp_name

    try:
        sqlite_scene.mark_ended_scene(history_db, name)
    except error.SceneNotFoundError as e:
        raise e
    except error.LastActiveSceneError as e:
        raise e
    else:
        sqlite_scene.end_scene(current_scene_db, name)
        display_scene.display_end_scene_success(name)
        return (name)
예제 #2
0
def current_scene(scene_root, history_db):
    """calls the scene init and displays the current scene from the sqlite history db"""
    from src.praxxis.sqlite import sqlite_scene
    from src.praxxis.display import display_scene

    current_scene_ref = sqlite_scene.get_current_scene(history_db)
    display_scene.display_current_scene(current_scene_ref)
    return current_scene_ref
예제 #3
0
def list_scene(root, history_db):
    """lists scenes by fetching from sqlite db"""
    from src.praxxis.sqlite import sqlite_scene
    from src.praxxis.display import display_scene

    ended_scenes = sqlite_scene.get_ended_scenes(history_db)
    active_scenes = sqlite_scene.get_active_scenes(history_db)
    current_scene = sqlite_scene.get_current_scene(history_db)

    sqlite_scene.dump_scene_list(history_db)

    sqlite_scene.write_scene_list(history_db, ended_scenes)
    sqlite_scene.write_scene_list(history_db, active_scenes)
    sqlite_scene.write_scene_list(history_db, [(current_scene,)])

    display_scene.display_list_scene(ended_scenes, active_scenes, current_scene)

    return(ended_scenes + active_scenes)
예제 #4
0
def delete_scene(args, scene_root, history_db):
    """deletes a specified scene, including all its data"""
    import shutil
    import os

    from src.praxxis.scene import current_scene
    from src.praxxis.sqlite import sqlite_scene
    from src.praxxis.display import display_scene
    from src.praxxis.util import error
    from src.praxxis.scene import scene

    if hasattr(args, "name"):
        if(args.name is None):
            name = sqlite_scene.get_current_scene(history_db)
        else:
            name = args.name
    else:
        name = args

    try:
        tmp_name = scene.get_scene_by_ordinal(args, name, history_db)
    except error.SceneNotFoundError as e:
        raise e
    except error.EndEndedSceneError as e:
        pass
        
    if tmp_name is not None:
        name = tmp_name

    directory = os.path.join(scene_root, name)

    if os.path.exists(directory):
        from src.praxxis.util import rmtree
        try:
            sqlite_scene.delete_scene(history_db, name)
            rmtree.rmtree(directory)
            display_scene.display_delete_scene_success(name)
            return name
        except error.LastActiveSceneError as e:
            raise e
    else:
        raise error.SceneNotFoundError(name)
예제 #5
0
def history(history_db, library_db, current_scene_db):
    """displays the notebook history of the sceen"""
    from src.praxxis.sqlite import sqlite_scene
    from src.praxxis.sqlite import sqlite_notebook
    from src.praxxis.display import display_scene

    curr_scene = sqlite_scene.get_current_scene(history_db)

    notebook_history = sqlite_scene.get_notebook_history(current_scene_db)
    display_scene.display_history(curr_scene, notebook_history)

    # get paths and format for writing into notebook list
    notebooks = []
    for notebook_info in notebook_history:
        # pass the library_db, notebook name, notebook library
        notebook_data = sqlite_notebook.get_notebook(library_db,
                                                     notebook_info[1])[0]
        notebooks.insert(0, (notebook_data))
    sqlite_notebook.write_list(current_scene_db, notebooks)
    return notebooks
예제 #6
0
파일: roots.py 프로젝트: joelpires/praxxis
def get_current_scene_db(scene_root, history_db):
    """calls the function to get the location of the history db"""
    import os
    from src.praxxis.sqlite import sqlite_scene
    scene = sqlite_scene.get_current_scene(history_db)
    return os.path.join(scene_root, scene, "%s.db" % (scene))