示例#1
0
    def _dump_peer(self, peer_descriptor, dump_file, dump_dir):
        ser = peer_config_serializer.PeerConfigSerializerINI()
        base_config, parser = parse_peer_default_config(peer_descriptor.peer_id,
                                                        peer_descriptor.path)
        diff_src, diff_deps, diff_params = ser.difference(base_config, peer_descriptor.config)
        peer_file_name = None

        if diff_src or diff_deps or diff_params:
            peer_file_name = os.path.join(dump_dir, peer_descriptor.peer_id + '.ini')
            with codecs.open(peer_file_name, "w", "utf-8") as f:
                ser.serialize_diff(base_config, peer_descriptor.config, f)
        return peer_file_name
示例#2
0
    def _dump_peer(self, peer_descriptor, dump_file, dump_dir):
        ser = peer_config_serializer.PeerConfigSerializerJSON()
        base_config, parser = parse_peer_default_config(peer_descriptor.peer_id,
                                                        peer_descriptor.path)
        diff_src, diff_deps, diff_params = ser.difference(base_config, peer_descriptor.config)

        conf = '{}'
        if diff_src or diff_deps or diff_params:
            buf = io.BytesIO()
            ser.serialize_diff(base_config, peer_descriptor.config, buf)
            conf = unicode(buf.getvalue())
        return conf