[virt-tools-list] [virt-manager PATCH] inspection: fix check of null icon

Cole Robinson crobinso at redhat.com
Wed Jan 30 23:21:20 UTC 2019


On 1/30/19 12:28 PM, Pino Toscano wrote:
> Recently the Python binding of libguestfs was adapted to properly use
> bytes in APIs that return data, instead of (ab)using strings [1].
> This change was done only when built for Python 3, which has this
> distinct bytes and strings.
> 
> Because of that, now the 'icon == ""' (empty string) checks fail, using
> whatever inspect_get_icon() returns, including empty arrays of bytes.
> Hence, change the checks to use the length of the data as condition, as
> also the libguestfs Python API documentation says.  Leave also the
> checks for None, in the remote case the API will return None in the
> future for no data.
> 
> [1] https://github.com/libguestfs/libguestfs/commit/0ee02e0117527b86a31b2a88a14994ce7f15571f
> ---
>   virtManager/inspection.py | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/virtManager/inspection.py b/virtManager/inspection.py
> index ea6123b8..fde48474 100644
> --- a/virtManager/inspection.py
> +++ b/virtManager/inspection.py
> @@ -268,10 +268,10 @@ class vmmInspection(vmmGObject):
>           if filesystems_mounted:
>               # string containing PNG data
>               icon = g.inspect_get_icon(root, favicon=0, highquality=1)
> -            if icon == "" or icon is None:
> +            if icon is None or len(icon) == 0:
>                   # no high quality icon, try a low quality one
>                   icon = g.inspect_get_icon(root, favicon=0, highquality=0)
> -                if icon == "":
> +                if icon is None or len(icon) == 0:
>                       icon = None
>   
>               # Inspection applications.
> 

Thanks, pushed now

- Cole




More information about the virt-tools-list mailing list