示例#1
0
    def merge_current_plasma_state(self, msg):
        """
        Merge partial plasma state file with global master.  Newly updated
        plasma state copied to caller's workdir.
        Exception raised on copy error.

        *msg.args*:

          0. partial_state_file
          1. target_state_file
          2. log_file: stdout for merge process if not ``None``
        """
        partial_state_file = msg.args[0]
        target_state_file = msg.args[1]
        log_file = msg.args[2]

        #fwk_bin_path = sys.path[0]
        #update_state = os.path.join(fwk_bin_path, 'update_state')
        update_state = 'update_state'
        plasma_work_dir = os.path.dirname(target_state_file)
        component_work_dir = os.path.dirname(partial_state_file)
        current_plasma_state = os.path.basename(target_state_file)

        merge_stdout = sys.stdout
        if (log_file):
            log_fullpath = os.path.join(component_work_dir, log_file)
            try:
                merge_stdout = open(log_fullpath, 'w')
            except:
                self.fwk.exception('Error opening log file %s : using stdout',
                                   log_fullpath)

        try:
            retval = subprocess.call([
                update_state, '-input', target_state_file, '-updates',
                partial_state_file
            ],
                                     stdout=merge_stdout,
                                     stderr=subprocess.STDOUT)
        except Exception:
            self.fwk.exception(
                'Error calling update_state - probably not found in $PATH')
            raise

        if (retval != 0):
            return retval
        try:
            ipsutil.copyFiles(plasma_work_dir, current_plasma_state,
                              component_work_dir)
        except Exception, e:
            self.fwk.exception(
                'Error refreshing local copy of current plasma state file in directory %s',
                component_work_dir)
            raise
示例#2
0
    def finalize(self, timeStamp=0.0):
        print('dakota_model_driver: finalize')

        self.services.stage_plasma_state()

        current_dakota_cost_file = self.services.get_config_param(
            'CURRENT_DAKOTA_COST_FILE')
        shutil.copyfile(current_dakota_cost_file, self.OUTPUT_FILES)

        root_directory = self.services.get_config_param('SIM_ROOT')
        current_directory = self.services.get_working_dir()
        ipsutil.copyFiles(current_directory, self.OUTPUT_FILES, root_directory)
示例#3
0
    def update_state(self, msg):
        """
        Copy plasma state files from source dir to target dir.  Return 0.
        Exception raised on copy error.

        *msg.args*:

          0. state_files
          1. source_dir
          2. target_dir
        """
        state_files = msg.args[0]
        source_dir = msg.args[1]
        target_dir = msg.args[2]
        try:
            ipsutil.copyFiles(source_dir, state_files, target_dir)
        except Exception, e:
            self.fwk.exception('Error updating state files from directory %s',
                               source_dir)
            raise
示例#4
0
        # assume that it was in the directory that the IPS was launched from.
        # NOTE: This is not necessarily where the IPS is installed.
        if not self.config_files[0].startswith("/"):
            self.conf_file_loc = self.cwd
        else:
            (head, tail) = os.path.split(os.path.abspath(self.config_files[0]))
            self.conf_file_loc = head
        if not self.platform_file.startswith("/"):
            self.plat_file_loc = self.cwd
        else:
            (head, tail) = os.path.split(os.path.abspath(self.platform_file))
            self.plat_file_loc = head

        #print 'conf_file_loc =', self.conf_file_loc
        #print 'plat_file_loc =', self.plat_file_loc
        ipsutil.copyFiles(self.conf_file_loc, self.config_files,
                          self.simRootDir)
        ipsutil.copyFiles(self.plat_file_loc, self.platform_file,
                          self.simRootDir)

        #sim_comps = services.fwk.config_manager.get_component_map()
        sim_comps = services.fwk.config_manager.get_all_simulation_components_map(
        )
        registry = services.fwk.comp_registry
        # Redoing the same container_file name calculation as in configuration manager because I
        # can't figure out where to put it such that I can get it where I need
        self.container_file = os.path.basename(
            services.get_config_param(
                'SIM_ROOT')) + os.path.extsep + container_ext
        #Remove existing container file in case we are restarting an old simulation in the same directory
        try:
            os.remove(self.container_file)