예제 #1
0
    def update_slices(self, path, project = None, sample = None,
                      info = None, timestring = None):
        """
        Creates and uploads slice images for a single NetCDF data set at
        location <path>. If <project> and <sample> are not specified,
        they are extracted from the absolute path. Additional information
        is passed in <info> and <timestring>.
        
        The response received from Plexus is written to self.output.
        """

        if not (info.get('IdExt') or info.get('IdInt')):
            return

        seen = info['Images']

        if self.slices_missing(seen, SLICE_SIZES):
            if self.dry_run:
                s = slices(path, seen, self.replace, true)
                for (data, name, action) in s:
                    self.print_action(project, sample, os.path.dirname(path),
                                      name, action)
            else:
                history = History(nc3info(path), path,
                                  time.gmtime(os.path.getmtime(path)))
                main = history.main_process().record
                meta = dict((k, main[k]) for k in ["data_file",
                                                   "data_type",
                                                   "date",
                                                   "domain",
                                                   "identifier",
                                                   "name",
                                                   "predecessors",
                                                   "process",
                                                   "run_by"])
                meta['path'] = os.path.abspath(path)

                s = slices(path, seen, self.replace, self.mock_slices,
                           sizes = SLICE_SIZES, info = meta)
                for (data, name, action) in s:
                    self.upload_files(project, sample, timestring,
                                      ((data, name),), info)
        else:
            self.log.info("Slices look complete. Skipped slice generation.")