X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FGPG.py;h=1dcc0cf4db90d5cf384462f28e28ade13d38d742;hb=19d4a01ccf66af9e00914351b3eacd5fc880f988;hp=97187e54697638d16937db86586c5c0f183c8b09;hpb=f5cd72e35593c96b9996ab4e49674cccc7525c48;p=plcapi.git diff --git a/PLC/GPG.py b/PLC/GPG.py index 97187e5..1dcc0cf 100644 --- a/PLC/GPG.py +++ b/PLC/GPG.py @@ -7,19 +7,15 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id$ -# $URL$ -# import os import xmlrpclib import shutil from types import StringTypes from StringIO import StringIO -from xml.dom import minidom -from xml.dom.ext import Canonicalize from subprocess import Popen, PIPE, call from tempfile import NamedTemporaryFile, mkdtemp +from lxml import etree from PLC.Faults import * @@ -31,16 +27,14 @@ def canonicalize(args, methodname = None, methodresponse = False): """ xml = xmlrpclib.dumps(args, methodname, methodresponse, encoding = 'utf-8', allow_none = 1) - dom = minidom.parseString(xml) - + dom = etree.fromstring(xml) + canonical=etree.tostring(dom) + # pre-f20 version was using Canonicalize from PyXML + # from xml.dom.ext import Canonicalize # Canonicalize(), though it claims to, does not encode unicode # nodes to UTF-8 properly and throws an exception unless you write # the stream to a file object, so just encode it ourselves. - buf = StringIO() - Canonicalize(dom, output = buf) - xml = buf.getvalue().encode('utf-8') - - return xml + return canonical.encode('utf-8') def gpg_export(keyring, armor = True): """