File fix-inspector-module-export-function-bsc-1097531-480.patch of Package salt.23536
From 238b17c8a8e807d8701303547efc85c9e932e18f Mon Sep 17 00:00:00 2001
From: Victor Zhestkov <vzhestkov@suse.com>
Date: Fri, 28 Jan 2022 16:44:45 +0300
Subject: [PATCH] Fix inspector module export function (bsc#1097531)
(#480)
---
salt/modules/inspectlib/fsdb.py | 8 ++++----
salt/modules/inspectlib/kiwiproc.py | 2 +-
salt/modules/inspectlib/query.py | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/salt/modules/inspectlib/fsdb.py b/salt/modules/inspectlib/fsdb.py
index 2874932b0a..939d34cf53 100644
--- a/salt/modules/inspectlib/fsdb.py
+++ b/salt/modules/inspectlib/fsdb.py
@@ -140,7 +140,7 @@ class CsvDB(object):
return self._tables.keys()
def _load_table(self, table_name):
- with gzip.open(os.path.join(self.db_path, table_name), "rb") as table:
+ with gzip.open(os.path.join(self.db_path, table_name), "rt") as table:
return OrderedDict(
[tuple(elm.split(":")) for elm in next(csv.reader(table))]
)
@@ -187,7 +187,7 @@ class CsvDB(object):
"""
get_type = lambda item: str(type(item)).split("'")[1]
if not os.path.exists(os.path.join(self.db_path, obj._TABLE)):
- with gzip.open(os.path.join(self.db_path, obj._TABLE), "wb") as table_file:
+ with gzip.open(os.path.join(self.db_path, obj._TABLE), "wt") as table_file:
csv.writer(table_file).writerow(
[
"{col}:{type}".format(col=elm[0], type=get_type(elm[1]))
@@ -215,7 +215,7 @@ class CsvDB(object):
db_obj = self.get(obj.__class__, eq=fields)
if db_obj and distinct:
raise Exception("Object already in the database.")
- with gzip.open(os.path.join(self.db_path, obj._TABLE), "a") as table:
+ with gzip.open(os.path.join(self.db_path, obj._TABLE), "at") as table:
csv.writer(table).writerow(self._validate_object(obj))
def update(self, obj, matches=None, mt=None, lt=None, eq=None):
@@ -321,7 +321,7 @@ class CsvDB(object):
:return:
"""
objects = []
- with gzip.open(os.path.join(self.db_path, obj._TABLE), "rb") as table:
+ with gzip.open(os.path.join(self.db_path, obj._TABLE), "rt") as table:
header = None
for data in csv.reader(table):
if not header:
diff --git a/salt/modules/inspectlib/kiwiproc.py b/salt/modules/inspectlib/kiwiproc.py
index 066335bdf2..fc69f6b7d4 100644
--- a/salt/modules/inspectlib/kiwiproc.py
+++ b/salt/modules/inspectlib/kiwiproc.py
@@ -82,7 +82,7 @@ class KiwiExporter(object):
[
line
for line in minidom.parseString(
- etree.tostring(root, encoding="UTF-8", pretty_print=True)
+ etree.tostring(root, encoding="UTF-8")
)
.toprettyxml(indent=" ")
.split("\n")
diff --git a/salt/modules/inspectlib/query.py b/salt/modules/inspectlib/query.py
index ed0167f678..34a30ff21b 100644
--- a/salt/modules/inspectlib/query.py
+++ b/salt/modules/inspectlib/query.py
@@ -78,7 +78,7 @@ class SysInfo(object):
for dev, dev_data in salt.utils.fsutils._blkid().items():
dev = self._get_disk_size(dev)
device = dev.pop("device")
- dev["type"] = dev_data["type"]
+ dev["type"] = dev_data.get("type", "UNKNOWN")
data[device] = dev
return data
--
2.34.1