def _add_to_version_control(self, synoptic_name, commit_message=None):
     # Add to version control
     try:
         self._vc.add(FILEPATH_MANAGER.get_synoptic_path(synoptic_name))
     except Exception as err:
         raise AddToVersionControlException(err)
     if commit_message is not None:
         try:
             self._vc.commit(commit_message)
         except Exception as err:
             raise CommitToVersionControlException(err)
    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)
 def test_synoptic_file_path_correct(self):
     synoptic = "test"
     self.assertEqual(os.path.join(self.path, SYNOPTIC_DIRECTORY, synoptic) + ".xml",
                      FILEPATH_MANAGER.get_synoptic_path(synoptic))
 def _update_version_control_post_delete(self, files):
     for synoptic in files:
         self._vc.remove(FILEPATH_MANAGER.get_synoptic_path(synoptic))
     self._vc.commit("Deleted %s" % ', '.join(list(files)))