示例#1
0
def update_flagfile(flagfile_fn, flag_name, flag_value):
    """Updates a flagfile on disk to a new value.

    Args:
        flagfile_fn (str): Path to the flagfile.
        flag_name (str): Name of the flag.
        flag_value (_): New value of the flag.
    """
    flags = get_flags_from_flagfile(flagfile_fn)
    flags[flag_name] = flag_value
    write_flagfile(flagfile_fn, flags)
示例#2
0
def grab_flag_value_from_file(flagfile_fn, flag_name):
    """Parse a flag value from a flagfile.

    Args:
        flagfile_fn (str): Path to the flagfile.
        flag_name (str): Name of the flag.

    Returns:
        _: Value corresponding to the flag. If the flag does not exist in
            the flagfile, an empty result will be given.
    """
    flags = get_flags_from_flagfile(flagfile_fn)
    return flags[flag_name] if flag_name in flags else ""
示例#3
0
 def get_render_flags(self, type):
     flags_dir = posixpath.join(self.local_project_root, "flags")
     flagfile_fn = posixpath.join(flags_dir, f"render_{type}.flags")
     flags_render = get_flags_from_flagfile(flagfile_fn)
     return flags_render
示例#4
0
    def update_flags_from_data(self, flags):
        """Updates flags from the UI elements.

        Args:
            flags (dict[str, _]): Flags corresponding to the tab default binary.
        """
        dlg = self.dlg
        rig_fn = getattr(self, "path_rig_json", "")
        flags["rig"] = rig_fn
        flags["input_root"] = self.parent.path_project
        flags["output_root"] = self.path_video
        flags["log_dir"] = self.path_logs
        flags["width"] = dlg.val_export_options_res.text()
        flags["first"] = dlg.dd_export_data_first.currentText()
        flags["last"] = dlg.dd_export_data_last.currentText()
        flags["force_recompute"] = dlg.cb_export_recompute.isChecked()

        color_type = dlg.dd_export_data_type.currentText()
        if color_type == "background_color":
            flags["color"] = self.path_bg_color
            flags["disparity"] = self.path_bg_disparity
            flags["color_type"] = "background_color"
            flags["disparity_type"] = "background_disp"
        else:
            flags["color"] = self.path_video_color
            flags["disparity"] = self.path_video_disparity
            flags["color_type"] = "color"
            flags["disparity_type"] = "disparity"

        if self.is_farm and self.parent.is_aws:
            flags["master"] = ""
            flags["workers"] = ""
            flags["cloud"] = "aws"

            rig_bn = os.path.basename(flags["rig"])
            flags["input_root"] = self.parent.ui_flags.project_root
            flags["output_root"] = os.path.join(
                self.parent.ui_flags.project_root, config.OUTPUT_ROOT_NAME)
            flags["rig"] = os.path.join(self.parent.ui_flags.project_root,
                                        "rigs", rig_bn)
            flags["log_dir"] = os.path.join(flags["output_root"], "logs")

        elif self.is_farm and self.parent.is_lan:
            flags["master"] = self.parent.ui_flags.master
            flags["workers"] = ",".join(
                dlg.dd_export_farm_workers.checkedItems())
            flags["cloud"] = ""

            flags["username"] = self.parent.ui_flags.username
            flags["password"] = self.parent.ui_flags.password

        else:  # local
            flags["master"] = ""
            flags["workers"] = ""
            flags["cloud"] = ""

        flags["file_type"] = dlg.dd_export_data_file_type.currentText()
        flags["format"] = self.get_format()
        is6dof = flags["format"].startswith("6dof")
        if is6dof:
            flags["format"] = "6dof"
        flags["run_convert_to_binary"] = (
            is6dof and "Meshing" in dlg.dd_export_data_format.currentText())
        flags["run_fusion"] = (is6dof and "Striping"
                               in dlg.dd_export_data_format.currentText())
        flags["run_simple_mesh_renderer"] = not is6dof
        flags["color_scale"] = self.get_color_scale(flags["width"], color_type)

        if self.parent.is_aws:
            create_flagfile = os.path.join(
                self.path_flags,
                self.app_name_to_flagfile[self.app_aws_create])
            if os.path.exists(create_flagfile):
                create_flags = get_flags_from_flagfile(create_flagfile)
                if "cluster_size" in create_flags:
                    dlg.spin_export_farm_num_workers.setValue(
                        int(create_flags["cluster_size"]))
                if "instance_type" in create_flags:
                    dlg.dd_export_farm_ec2.setCurrentText(
                        create_flags["instance_type"])