From 2cd20e47fa4d189c0fee963259f489fff7a23982 Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: Jun 28 2018 16:22:35 +0000 Subject: Pass to fmf Tree a unicode string as a parameter. Signed-off-by: Andrei Stepanov --- diff --git a/inventory/standard-inventory-qcow2 b/inventory/standard-inventory-qcow2 index 7952c03..4a60ff3 100755 --- a/inventory/standard-inventory-qcow2 +++ b/inventory/standard-inventory-qcow2 @@ -112,6 +112,14 @@ formatter = logging.Formatter(log_format) conhandler.setFormatter(formatter) logger.addHandler(conhandler) +# Temporary fix for issue #233. Strings in Python3 are all unicode. To get a +# unicode string in Python2 necessary to use `unicode()`. fmf.Tree() expects a +# unicode string even in Python2 module. +try: + UNICODE_EXISTS = bool(type(unicode)) +except NameError: + unicode = str + def main(argv): parser = argparse.ArgumentParser(description="Inventory for a QCow2 test image") @@ -200,7 +208,7 @@ class FmfMetadataTree(object): if self.path != path or self.tree is None: FmfMetadataTree.path = path try: - FmfMetadataTree.tree = fmf.Tree(path) + FmfMetadataTree.tree = fmf.Tree(unicode(path)) except Exception: """Fmf initialization failed. Do not try initialize further for this path. """