Ejemplo n.º 1
0
def get_projects(indir="../projects", strict=False):
    to_output = {"Projects": {"Project": []}}
    projects = []

    campus_grid_ids = get_campus_grid_ids(indir)
    vos_data = get_vos_data(os.path.join(indir, "../virtual-organizations"),
                            None)

    for file in os.listdir(indir):
        if not file.endswith(".yaml"):
            continue
        elif file.endswith("_CAMPUS_GRIDS.yaml"):
            continue
        try:
            project = get_one_project(os.path.join(indir, file),
                                      campus_grid_ids, vos_data)
            projects.append(project)
        except yaml.YAMLError:
            if strict:
                raise
            else:
                # load_yaml_file() already logs the specific error
                log.error("skipping (non-strict mode)")
                continue
        except Exception as e:
            if strict:
                raise
            log.exception("Skipping (non-strict mode); exception info follows")
            continue

    to_output["Projects"]["Project"] = projects

    return to_output
Ejemplo n.º 2
0
 def get_vos_data(self) -> VOsData:
     if self.vos_data.should_update():
         ok = self._update_topology_repo()
         self.vos_data.update(vo_reader.get_vos_data(
             self.vos_dir, self.get_contacts_data()),
                              bump_timestamp=ok)
     return self.vos_data.data
Ejemplo n.º 3
0
    def get_vos_data(self) -> VOsData:
        if self.vos_data.should_update():
            ok = self._update_topology_repo()
            if ok:
                self.vos_data.update(vo_reader.get_vos_data(self.vos_dir, self.get_contacts_data()))
            else:
                self.vos_data.try_again()

        return self.vos_data.data
Ejemplo n.º 4
0
    def get_vos_data(self) -> VOsData:
        if self.vos_data.should_update():
            ok = self._update_topology_repo()
            if ok:
                try:
                    self.vos_data.update(vo_reader.get_vos_data(self.vos_dir, self.get_contacts_data(), strict=self.strict))
                except Exception:
                    if self.strict:
                        raise
                    log.exception("Failed to update VOs")
                    self.vos_data.try_again()
            else:
                self.vos_data.try_again()

        return self.vos_data.data
Ejemplo n.º 5
0
def _get_vos_data():
    global _vos_data
    if not _vos_data:
        _vos_data = get_vos_data("../virtual-organizations", _get_contacts_data())
    return _vos_data