Am 12-02-2014 00:38, schrieb Daniel Barboza:
+import libvirt
import os
+import socket
+import string
import time
+import urlparse
import uuid
-from xml.etree import ElementTree
-import libvirt
from cherrypy.process.plugins import BackgroundTask
+from lxml import etree, objectify
+from xml.etree import ElementTree
from kimchi import vnc
from kimchi import xmlutils
@@ -36,7 +40,8 @@ from kimchi.model.config import CapabilitiesModel
from kimchi.model.templates import TemplateModel
from kimchi.model.utils import get_vm_name
from kimchi.screenshot import VMScreenshot
-from kimchi.utils import run_setfacl_set_attr, template_name_from_uri
+from kimchi.utils import kimchi_log, run_setfacl_set_attr
+from kimchi.utils import template_name_from_uri
The import order is defined as: 1)
standard libraries; 2) third party
libraries; 3) Kimchi libraries.
So libvirt should be on the second group, as it was before, and the XML
packages should be on the first group (they're python standard
libraries, right?).
@@ -40,3 +40,8 @@ def xml_item_update(xml, xpath, value):
item = root.find(xpath)
item.text = value
return ElementTree.tostring(root, encoding="utf-8")
+
+def xml_get_child(xml, xpath):
+ root = ElementTree.fromstring(xml)
+ item = root.find(xpath)
+ return ElementTree.tostring(item, encoding="utf-8")
Top-level
elements (like the function "xml_get_child") should have two
blank lines between themselves.