Exemplo n.º 1
0
def add_tile_colliders(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path)

        check_configuration(script_settings, msfs_project)

        if script_settings.backup_enabled:
            msfs_project.backup(
                Path(os.path.abspath(__file__)).stem.replace(
                    SCRIPT_PREFIX, str()))

        isolated_print(EOL)
        msfs_project.add_tile_colliders()

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + constants.CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + constants.CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + constants.CEND)
def optimize_scenery(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path)

        check_configuration(
            script_settings,
            msfs_project,
            check_optimisation=True,
            check_lily_texture_packer=script_settings.bake_textures_enabled)

        if script_settings.backup_enabled:
            msfs_project.backup(
                Path(os.path.abspath(__file__)).stem.replace(
                    SCRIPT_PREFIX, str()))

        clean_scene()
        msfs_project.optimize(script_settings)

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + CEND)
def compress_built_package(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path,
                                   fast_init=True)

        check_configuration(script_settings,
                            msfs_project,
                            check_built_package=True,
                            check_compressonator=True)

        isolated_print(EOL)
        print_title("COMPRESS BUILT PACKAGE")

        msfs_project.compress_built_package(script_settings)

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + constants.CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + constants.CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + constants.CEND)
Exemplo n.º 4
0
def prepare_payload(trainer_folder_name,
                    payload_folder_name="payload",
                    TRAINER_FILES=[
                        'README.md', 'setup.py', 'trainer/model.py',
                        'trainer/task.py', 'trainer/__init__.py',
                        'trainer/GCSproxy.py'
                    ]):
    """
    zip python code and build package
    """
    logging.warning(
        "relna:client:prepare_payload: preparing payload from {} to {}".format(
            trainer_folder_name, payload_folder_name))
    try:
        os.mkdir(payload_folder_name)
    except:
        pass
    utils.zip_trainer(trainer_folder_name,
                      zip_name=os.path.join(payload_folder_name,
                                            "trainer.zip"),
                      TRAINER_FILES=TRAINER_FILES)
    utils.build_package(trainer_folder_name, package_name=payload_folder_name)
    logging.warning(
        "relna:client:prepare_payload: payload prepared succesfully at  {}".
        format(payload_folder_name))
Exemplo n.º 5
0
def prepare_payload(
        trainer_folder_name,
        payload_folder_name="payload"
        ):
    """
    zip python code and build package
    """
    logging.warning("relna:client:prepare_payload: preparing payload from {} to {}".format(trainer_folder_name, payload_folder_name))
    try: os.mkdir(payload_folder_name)
    except: pass
    utils.zip_trainer(
            trainer_folder_name,
            zip_name=os.path.join(payload_folder_name, "trainer.zip"))
    utils.build_package(
            trainer_folder_name,
            package_name=payload_folder_name)
    logging.warning("relna:client:prepare_payload: payload prepared succesfully at  {}".format(payload_folder_name))
def merge_sceneries(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path)
        project_folder_to_merge = os.path.dirname(
            script_settings.project_path_to_merge) + os.path.sep
        project_name_to_merge = os.path.relpath(
            script_settings.project_path_to_merge,
            start=project_folder_to_merge)
        msfs_project_to_merge = MsfsProject(
            script_settings.projects_path, project_name_to_merge,
            script_settings.definition_file_to_merge,
            script_settings.author_name, script_settings.sources_path)

        check_configuration(script_settings, msfs_project)
        check_configuration(script_settings, msfs_project_to_merge)

        if script_settings.backup_enabled:
            msfs_project.backup(
                Path(os.path.abspath(__file__)).stem.replace(
                    SCRIPT_PREFIX, str()))

        msfs_project.merge(msfs_project_to_merge)

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + CEND)