From 3ef73c8d8fb21888d1666f17a6bc06ba455f9e83 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Thu, 12 Dec 2019 12:47:03 +0100 Subject: [PATCH] Remove version check for encoding Virtualbmc is now Python 3 only, encoding for ET can be set to unicode only. Removing import sys from vbmc.py as it was used only for that check. Change-Id: I35ac19308337f9fb603efa5b8a3dc97aea234cbc --- virtualbmc/vbmc.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/virtualbmc/vbmc.py b/virtualbmc/vbmc.py index 1ddaafc..2dc18d2 100644 --- a/virtualbmc/vbmc.py +++ b/virtualbmc/vbmc.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import sys import xml.etree.ElementTree as ET import libvirt @@ -103,11 +102,7 @@ class VirtualBMC(bmc.Bmc): boot_element = ET.SubElement(os_element, 'boot') boot_element.set('dev', device) - # conn.defineXML can't take bytes but - # in py3 ET.tostring returns bytes unless "unicode" - # in py2 "unicode" is unknown so specify "utf8" instead - enc = sys.version_info[0] < 3 and "utf8" or "unicode" - conn.defineXML(ET.tostring(tree, encoding=enc)) + conn.defineXML(ET.tostring(tree, encoding="unicode")) except libvirt.libvirtError: LOG.error('Failed setting the boot device %(bootdev)s for ' 'domain %(domain)s', {'bootdev': device,