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: 04bb35bd86 (live: rewrite software inventory)
more_events
Jose M. Guisado 2023-05-09 16:54:36 +02:00
parent 66a464f7d0
commit 0c6dd12f4c
1 changed files with 10 additions and 5 deletions

View File

@ -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):