def _load_initial(self): """Create the PVs for all the synoptics found in the synoptics directory.""" for f in self._file_io.get_list_synoptic_files(self._directory): # Load the data, checking the schema try: data = self._file_io.read_synoptic_file(self._directory, f) ConfigurationSchemaChecker.check_xml_matches_schema(os.path.join(self._schema_folder, SYNOPTIC_SCHEMA_FILE), data, "Synoptic") # Get the synoptic name self._create_pv(data) self._add_to_version_control(f[0:-4]) except VersionControlException as err: print_and_log(str(err), "MAJOR") except Exception as err: print_and_log("Error creating synoptic PV: %s" % str(err), "MAJOR") try: self._vc.commit("Blockserver started, synoptics updated") except Exception as err: print_and_log("Unable to update synoptics while starting the blockserver: %s" % str(err), "MAJOR")
def save_synoptic_xml(self, xml_data): """Saves the xml under the filename taken from the xml name tag. Args: xml_data (string): The XML to be saved """ try: # Check against schema ConfigurationSchemaChecker.check_xml_matches_schema(os.path.join(self._schema_folder, SYNOPTIC_SCHEMA_FILE), xml_data, "Synoptic") # Update PVs self._create_pv(xml_data) except Exception as err: print_and_log(err) raise name = self._get_synoptic_name_from_xml(xml_data) save_path = FILEPATH_MANAGER.get_synoptic_path(name) self._file_io.write_synoptic_file(name, save_path, xml_data) self._add_to_version_control(name, "%s modified by client" % name) print_and_log("Synoptic saved: " + name)