Exemple #1
0
        if len(net_diff.keys()) == 0:
            print format_message('WLSDPLY-05710')
            print BLANK_LINE
            return 0

        if self.output_dir:
            fos = None
            writer = None
            file_name = None
            try:
                print format_message('WLSDPLY-05711', self.output_dir)
                print BLANK_LINE
                file_name = self.output_dir + '/diffed_model.json'
                fos = JFileOutputStream(file_name, False)
                writer = JPrintWriter(fos, True)
                json_object = PythonToJson(net_diff)
                json_object._write_dictionary_to_json_file(net_diff, writer)
                writer.close()
                file_name = self.output_dir + '/diffed_model.yaml'
                fos = JFileOutputStream(file_name, False)
                writer = JPrintWriter(fos, True)
                pty = PythonToYaml(net_diff)
                pty._write_dictionary_to_yaml_file(net_diff, writer)
                writer.close()
            except JIOException, ioe:
                if fos:
                    fos.close()
                if writer:
                    writer.close()
                _logger.severe('WLSDPLY-05708', file_name, ioe.getLocalizedMessage(),
                               error=ioe, class_name=_class_name, method_name=_method_name)
        print format_message('WLSDPLY-05706', self.current_dict_file, self.past_dict_file)
        print BLANK_LINE
        if len(change_model.keys()) == 0:
            print format_message('WLSDPLY-05710')
            print BLANK_LINE
            return 0

        if self.output_dir:
            file_name = None
            try:
                print format_message('WLSDPLY-05711', self.output_dir)
                print BLANK_LINE

                # write the change model as a JSON file
                file_name = self.output_dir + '/diffed_model.json'
                json_object = PythonToJson(change_model)
                json_object.write_to_json_file(file_name)

                # write the change model as a YAML file
                file_name = self.output_dir + '/diffed_model.yaml'
                pty = PythonToYaml(change_model)
                pty.write_to_yaml_file(file_name)

            except YamlException, ye:
                _logger.severe('WLSDPLY-05708', file_name, ye.getLocalizedMessage(),
                               error=ye, class_name=_class_name, method_name=_method_name)
                return 2
        else:
            # write the change model to standard output in YAML format
            print format_message('WLSDPLY-05707')
            print BLANK_LINE