diff options
author | Pino Toscano <ptoscano@redhat.com> | 2019-04-18 16:08:30 +0200 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2019-04-18 13:44:34 -0400 |
commit | 83f1544d32bc89215899256f580ae1094a633960 (patch) | |
tree | d6924b7785380f8754454ef4fb958e156dbd3f9b /virtManager | |
parent | a9277d22b5167b71f57a18567eae85d59129d19f (diff) | |
download | virt-manager-83f1544d32bc89215899256f580ae1094a633960.tar.gz |
inspection: create and use a separate vmmInspectionApplication
Instead of passing around the raw results of
g.inspect_list_applications(), create an helper vmmInspectionApplication
object with the data of an inspected application that we use. This is
done for different reasons:
- when using the data, it is easier to use member variables instead of
looking up values in a dictionary
- we keep only the data needed, slightly lowering the memory/objects
used for the inspected applications
- it will be easier to switch from g.inspect_list_applications() to
g.inspect_list_applications2() without changing code outside the
inspection code
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'virtManager')
-rw-r--r-- | virtManager/details.py | 28 | ||||
-rw-r--r-- | virtManager/domain.py | 11 | ||||
-rw-r--r-- | virtManager/inspection.py | 23 |
3 files changed, 46 insertions, 16 deletions
diff --git a/virtManager/details.py b/virtManager/details.py index 1b0d5d02..381e2594 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -2528,22 +2528,22 @@ class vmmDetails(vmmGObjectUI): apps_model.clear() for app in apps: name = "" - if app["app_name"]: - name = app["app_name"] - if app["app_display_name"]: - name = app["app_display_name"] + if app.name: + name = app.name + if app.display_name: + name = app.display_name version = "" - if app["app_epoch"] > 0: - version += str(app["app_epoch"]) + ":" - if app["app_version"]: - version += app["app_version"] - if app["app_release"]: - version += "-" + app["app_release"] + if app.epoch > 0: + version += str(app.epoch) + ":" + if app.version: + version += app.version + if app.release: + version += "-" + app.release summary = "" - if app["app_summary"]: - summary = app["app_summary"] - elif app["app_description"]: - summary = app["app_description"] + if app.summary: + summary = app.summary + elif app.description: + summary = app.description pos = summary.find("\n") if pos > -1: summary = _("%(summary)s ...") % { diff --git a/virtManager/domain.py b/virtManager/domain.py index cb15b77f..54447a15 100644 --- a/virtManager/domain.py +++ b/virtManager/domain.py @@ -67,6 +67,17 @@ def start_job_progress_thread(vm, meter, progtext): t.start() +class vmmInspectionApplication(object): + def __init__(self): + self.name = None + self.display_name = None + self.epoch = None + self.version = None + self.release = None + self.summary = None + self.description = None + + class vmmInspectionData(object): def __init__(self): self.os_type = None diff --git a/virtManager/inspection.py b/virtManager/inspection.py index 4b183b5b..a682dea9 100644 --- a/virtManager/inspection.py +++ b/virtManager/inspection.py @@ -9,7 +9,7 @@ import threading from .baseclass import vmmGObject from .connmanager import vmmConnectionManager -from .domain import vmmInspectionData +from .domain import vmmInspectionApplication, vmmInspectionData def _inspection_error(_errstr): @@ -264,7 +264,26 @@ class vmmInspection(vmmGObject): # Inspection applications. try: - apps = g.inspect_list_applications(root) + gapps = g.inspect_list_applications(root) + # applications listing worked, so make apps a real list + # (instead of None) + apps = [] + for gapp in gapps: + app = vmmInspectionApplication() + if gapp["app_name"]: + app.name = gapp["app_name"] + if gapp["app_display_name"]: + app.display_name = gapp["app_display_name"] + app.epoch = gapp["app_epoch"] + if gapp["app_version"]: + app.version = gapp["app_version"] + if gapp["app_release"]: + app.release = gapp["app_release"] + if gapp["app_summary"]: + app.summary = gapp["app_summary"] + if gapp["app_description"]: + app.description = gapp["app_description"] + apps.append(app) except Exception: logging.exception("%s: exception while listing apps (ignored)", prettyvm) |