Exemplo n.º 1
0
def main():
    config = get_configuration()
    module = get_module(config["file"])
    scene_names_to_classes = dict(inspect.getmembers(module, is_scene))

    config["output_directory"] = os.path.join(
        ANIMATIONS_DIR, config["file"].replace(".py", ""))

    scene_kwargs = dict([(key, config[key]) for key in [
        "camera_config",
        "frame_duration",
        "skip_animations",
        "write_to_movie",
        "output_directory",
        "save_pngs",
        "movie_file_extension",
        "start_at_animation_number",
        "end_at_animation_number",
    ]])

    scene_kwargs["name"] = config["output_name"]
    if config["save_pngs"]:
        print "We are going to save a PNG sequence as well..."
        scene_kwargs["save_pngs"] = True
        scene_kwargs["pngs_mode"] = config["saved_image_mode"]

    for SceneClass in get_scene_classes(scene_names_to_classes, config):
        try:
            handle_scene(SceneClass(**scene_kwargs), **config)
            play_finish_sound()
        except:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            play_error_sound()
Exemplo n.º 2
0
def main(config):
    constants.init_directories(config)
    script_module = get_module(config["file"])
    pyclbr_module = pyclbr.readmodule(script_module.__name__)
    scene_names_to_pyclbr_classes = {
        name: pyclbr_class
        for name, pyclbr_class in pyclbr_module.items()
        if pyclbr_class.module == script_module.__name__
    }
    scene_names_to_classes = dict(
        inspect.getmembers(
            script_module,
            lambda x: inspect.isclass(x) and x.__name__ in
            scene_names_to_pyclbr_classes.keys(),
        ))

    # config["output_directory"] = os.path.join(
    #     VIDEO_DIR,
    #     config["file"].replace(".py", "")
    # )

    scene_kwargs = dict([(key, config[key]) for key in [
        "camera_config",
        "frame_duration",
        "skip_animations",
        "write_to_movie",
        "save_pngs",
        "movie_file_extension",
        "start_at_animation_number",
        "end_at_animation_number",
    ]])

    scene_kwargs["name"] = config["output_name"]
    if config["save_pngs"]:
        print("We are going to save a PNG sequence as well...")
        scene_kwargs["save_pngs"] = True
        scene_kwargs["pngs_mode"] = config["saved_image_mode"]

    exit_codes = []
    for scene_name in get_scene_classes(scene_names_to_pyclbr_classes, config):
        try:
            SceneClass = scene_names_to_classes[scene_name]
            handle_scene(SceneClass(**scene_kwargs), **config)
            exit_codes.append(play_finish_sound())
        except:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            exit_codes.append(play_error_sound())
    if any(exit_codes):
        sys.exit(1)
    else:
        sys.exit(0)
Exemplo n.º 3
0
def main():
    config = get_configuration()
    module = get_module(config["file"])
    scene_names_to_classes = dict(inspect.getmembers(module, is_scene))

    # config["output_directory"] = os.path.join(
    #     ANIMATIONS_DIR,
    #     config["file"].replace(".py", "")
    # )

    scene_kwargs = dict([
        (key, config[key])
        for key in [
            "camera_config",
            "frame_duration",
            "skip_animations",
            "write_to_movie",
            "save_pngs",
            "movie_file_extension",
            "start_at_animation_number",
            "end_at_animation_number",
        ]
    ])

    scene_kwargs["name"] = config["output_name"]
    if config["save_pngs"]:
        print "We are going to save a PNG sequence as well..."
        scene_kwargs["save_pngs"] = True
        scene_kwargs["pngs_mode"] = config["saved_image_mode"]

    for SceneClass in get_scene_classes(scene_names_to_classes, config):
        try:
            handle_scene(SceneClass(**scene_kwargs), **config)
            play_finish_sound()
        except:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            play_error_sound()