From 0c6dd12f4c743c998071fb31c80064b8c6ee40df Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 9 May 2023 16:54:36 +0200 Subject: sw_inventory: ignore invalid windows programs Don't raise exception if any windows program is missing DisplayName node in the windows registry. This attribute/node should contain the program's name. This name is used as the package's name in the software set (software inventory). This patch should be considered a hotfix, python-hivex does not report any helpful message about this error. (2023-05-09 14:43:13) ogClient: [ERROR] - Unexpected error Traceback (most recent call last): [...] RuntimeError: Success Before this patch, image creation *might* fail because it cannot create the software inventory associated with the image due to the previously described error. The software inventory is part of the response payload of the image creation command (see src/ogRest:image_create). Fixes: 04bb35bd86b5 (live: rewrite software inventory) --- src/utils/sw_inventory.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/utils/sw_inventory.py') diff --git a/src/utils/sw_inventory.py b/src/utils/sw_inventory.py index 5c93ad4..69c1f2c 100644 --- a/src/utils/sw_inventory.py +++ b/src/utils/sw_inventory.py @@ -9,6 +9,7 @@ import platform import re import os +import logging from collections import namedtuple @@ -38,11 +39,15 @@ def _fill_package_set(h, key, pkg_set): for child in childs for value in h.node_values(child) if h.value_key(value) == 'DisplayVersion'] for ch in valid_childs: - name = h.value_string(h.node_get_value(ch, 'DisplayName')) - value = h.node_get_value(ch, 'DisplayVersion') - version = h.value_string(value) - pkg = Package(name, version) - pkg_set.add(pkg) + try: + name = h.value_string(h.node_get_value(ch, 'DisplayName')) + value = h.node_get_value(ch, 'DisplayVersion') + version = h.value_string(value) + pkg = Package(name, version) + pkg_set.add(pkg) + except RuntimeError: + logging.warning('Unable to fill package set with invalid child') + pass def _fill_package_set_1(h, pkg_set): -- cgit v1.2.3-18-g5258