[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 1/1] QMP test code - qmp.py
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] Re: [PATCH 1/1] QMP test code - qmp.py |
Date: |
Wed, 7 Apr 2010 10:36:10 -0300 |
On Wed, 7 Apr 2010 03:40:32 +0300
Costas Drogos <address@hidden> wrote:
> Hello there,
>
> a very small patch to address two small issues:
>
> 1) The json state in python2.5 and python2.6. json module is included
> by default on python2.6, whereas you have to import simplejson in
> python2.5. I have this problem on Debian testing, so feel free to test
> if this is applicable in your distribution.
>
> 2) For qmp commands to work (e.g. query-kvm) we have to give first the
> command 'qmp_capabilities' because monitor is in 'Capabilities
> Negotiation mode' on startup. The patch takes care of issuing that
> command immediately after connecting.
>
> The patch is more of a hack to ease qmp testing and development.
I already have a new version of that script in the master branch of:
git://repo.or.cz/qemu/qmp-unstable.git
It fixes current problems and has other improvements, I didn't submit
it yet because I didn't test it much.
So, I will add a fix for the json problem and would appreciate any testing.
> diff --git a/QMP/qmp.py b/QMP/qmp.py
> index d9da603..f8581c4 100644
> --- a/QMP/qmp.py
> +++ b/QMP/qmp.py
> @@ -8,7 +8,15 @@
> # This work is licensed under the terms of the GNU GPL, version 2. See
> # the COPYING file in the top-level directory.
>
> -import socket, json
> +import socket
> +
> +from sys import version
> +ver = version[:3]
> +
> +if ver == '2.6':
> + import json
> +else:
> + import simplejson as json
This won't do what we want for 2.7 and newer, so a better if would be:
if sys.version_info < (2, 6):
import simplejson as json
else:
import json