summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-05-09 16:54:36 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-05-09 17:04:27 +0200
commit0c6dd12f4c743c998071fb31c80064b8c6ee40df (patch)
treea1f98bb95ecf1cdc3ce534f3a0a238786cbcccad /src
parent66a464f7d04b9b8abed578b7ba9456a50ee9a3f8 (diff)
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)
Diffstat (limited to 'src')
-rw-r--r--src/utils/sw_inventory.py15
1 files changed, 10 insertions, 5 deletions
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):